|
2 | 2 |
|
3 | 3 | const diagnostics = require('node:diagnostics_channel')
|
4 | 4 | const { test } = require('node:test')
|
5 |
| -const sget = require('simple-get').concat |
6 | 5 | const Fastify = require('../..')
|
7 |
| -const { getServerUrl } = require('../helper') |
8 | 6 | const Request = require('../../lib/request')
|
9 | 7 | const Reply = require('../../lib/reply')
|
10 | 8 |
|
11 |
| -test('diagnostics channel async events fire in expected order', (t, done) => { |
| 9 | +test('diagnostics channel async events fire in expected order', async t => { |
12 | 10 | t.plan(19)
|
13 | 11 | let callOrder = 0
|
14 | 12 | let firstEncounteredMessage
|
@@ -56,19 +54,12 @@ test('diagnostics channel async events fire in expected order', (t, done) => {
|
56 | 54 | }
|
57 | 55 | })
|
58 | 56 |
|
59 |
| - fastify.listen({ port: 0 }, function (err) { |
60 |
| - if (err) t.assert.ifError(err) |
| 57 | + t.after(() => { fastify.close() }) |
61 | 58 |
|
62 |
| - t.after(() => { fastify.close() }) |
| 59 | + const fastifyServer = await fastify.listen({ port: 0 }) |
63 | 60 |
|
64 |
| - sget({ |
65 |
| - method: 'GET', |
66 |
| - url: getServerUrl(fastify) + '/' |
67 |
| - }, (err, response, body) => { |
68 |
| - t.assert.ifError(err) |
69 |
| - t.assert.strictEqual(response.statusCode, 200) |
70 |
| - t.assert.deepStrictEqual(JSON.parse(body), { hello: 'world' }) |
71 |
| - done() |
72 |
| - }) |
73 |
| - }) |
| 61 | + const result = await fetch(fastifyServer + '/') |
| 62 | + t.assert.ok(result.ok) |
| 63 | + t.assert.strictEqual(result.status, 200) |
| 64 | + t.assert.deepStrictEqual(await result.json(), { hello: 'world' }) |
74 | 65 | })
|
0 commit comments