Skip to content

Commit

Permalink
test: migrate from tap to node:test and c8 (#312)
Browse files Browse the repository at this point in the history
  • Loading branch information
dancastillo authored Oct 30, 2024
1 parent 936870a commit 693c0f9
Show file tree
Hide file tree
Showing 7 changed files with 617 additions and 481 deletions.
2 changes: 0 additions & 2 deletions .taprc

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
"@fastify/ajv-compiler": "^4.0.0",
"@fastify/pre-commit": "^2.1.0",
"@types/node": "^22.7.7",
"c8": "^10.1.2",
"end-of-stream": "^1.4.4",
"express": "^4.19.2",
"form-auto-content": "^3.2.1",
"form-data": "^4.0.0",
"formdata-node": "^6.0.3",
"standard": "^17.1.0",
"tap": "^18.7.2",
"tinybench": "^3.0.0",
"tsd": "^0.31.0",
"undici": "^6.13.0"
Expand All @@ -31,7 +31,7 @@
"lint": "standard",
"test": "npm run lint && npm run test:unit && npm run test:typescript",
"test:typescript": "tsd",
"test:unit": "tap"
"test:unit": "c8 --100 node --test"
},
"repository": {
"type": "git",
Expand Down
16 changes: 8 additions & 8 deletions test/async-await.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const { test } = require('tap')
const { test } = require('node:test')
const inject = require('../index')

test('basic async await', async t => {
Expand All @@ -11,9 +11,9 @@ test('basic async await', async t => {

try {
const res = await inject(dispatch, { method: 'GET', url: 'http://example.com:8080/hello' })
t.equal(res.payload, 'hello')
t.assert.strictEqual(res.payload, 'hello')
} catch (err) {
t.fail(err)
t.assert.fail(err)
}
})

Expand All @@ -22,7 +22,7 @@ test('basic async await (errored)', async t => {
res.connection.destroy(new Error('kaboom'))
}

await t.rejects(inject(dispatch, { method: 'GET', url: 'http://example.com:8080/hello' }))
await t.assert.rejects(() => inject(dispatch, { method: 'GET', url: 'http://example.com:8080/hello' }), Error)
})

test('chainable api with async await', async t => {
Expand All @@ -34,9 +34,9 @@ test('chainable api with async await', async t => {
try {
const chain = inject(dispatch).get('http://example.com:8080/hello')
const res = await chain.end()
t.equal(res.payload, 'hello')
t.assert.strictEqual(res.payload, 'hello')
} catch (err) {
t.fail(err)
t.assert.fail(err)
}
})

Expand All @@ -48,8 +48,8 @@ test('chainable api with async await without end()', async t => {

try {
const res = await inject(dispatch).get('http://example.com:8080/hello')
t.equal(res.payload, 'hello')
t.assert.strictEqual(res.payload, 'hello')
} catch (err) {
t.fail(err)
t.assert.fail(err)
}
})
Loading

0 comments on commit 693c0f9

Please sign in to comment.