|
2 | 2 |
|
3 | 3 | const { test } = require('node:test')
|
4 | 4 | const diagnostics = require('node:diagnostics_channel')
|
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 sync events fire in expected order', (t, done) => { |
| 9 | +test('diagnostics channel sync events fire in expected order', async t => { |
12 | 10 | t.plan(10)
|
13 | 11 | let callOrder = 0
|
14 | 12 | let firstEncounteredMessage
|
@@ -40,19 +38,12 @@ test('diagnostics channel sync events fire in expected order', (t, done) => {
|
40 | 38 | }
|
41 | 39 | })
|
42 | 40 |
|
43 |
| - fastify.listen({ port: 0 }, function (err) { |
44 |
| - if (err) t.assert.ifError(err) |
| 41 | + t.after(() => { fastify.close() }) |
45 | 42 |
|
46 |
| - t.after(() => { fastify.close() }) |
| 43 | + const fastifyServer = await fastify.listen({ port: 0 }) |
47 | 44 |
|
48 |
| - sget({ |
49 |
| - method: 'GET', |
50 |
| - url: getServerUrl(fastify) + '/' |
51 |
| - }, (err, response, body) => { |
52 |
| - t.assert.ifError(err) |
53 |
| - t.assert.strictEqual(response.statusCode, 200) |
54 |
| - t.assert.deepStrictEqual(JSON.parse(body), { hello: 'world' }) |
55 |
| - done() |
56 |
| - }) |
57 |
| - }) |
| 45 | + const result = await fetch(fastifyServer + '/') |
| 46 | + t.assert.ok(result.ok) |
| 47 | + t.assert.strictEqual(result.status, 200) |
| 48 | + t.assert.deepStrictEqual(await result.json(), { hello: 'world' }) |
58 | 49 | })
|
0 commit comments