Skip to content

Commit

Permalink
chore: migrate from tap to node:test and c8 (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
inyourtime authored Nov 25, 2024
1 parent d2dd2b3 commit e63ff8f
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 24 deletions.
3 changes: 0 additions & 3 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 @@ -8,7 +8,7 @@
"scripts": {
"lint": "standard | snazzy",
"test": "npm run test:unit && npm run test:typescript",
"test:unit": "tap",
"test:unit": "c8 --100 node --test",
"test:typescript": "tsd"
},
"repository": {
Expand Down Expand Up @@ -39,10 +39,10 @@
"@fastify/pre-commit": "^2.1.0",
"@sinclair/typebox": "^0.34.3",
"ajv-formats": "^3.0.1",
"c8": "^10.1.2",
"fluent-json-schema": "^5.0.0",
"snazzy": "^9.0.0",
"standard": "^17.1.0",
"tap": "^18.7.1",
"tsd": "^0.31.0"
},
"pre-commit": [
Expand Down
4 changes: 2 additions & 2 deletions test/basic.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const t = require('tap')
const { test } = require('node:test')
const makeTest = require('./make-test')
const { join } = require('node:path')

Expand Down Expand Up @@ -325,7 +325,7 @@ const tests = [
]

tests.forEach(function (testConf) {
t.test(testConf.name, t => {
test(testConf.name, t => {
const options = {
schema: testConf.schema,
data: testConf.data,
Expand Down
12 changes: 6 additions & 6 deletions test/custom-ajv.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const t = require('tap')
const { test } = require('node:test')
const Ajv = require('ajv')
const makeTest = require('./make-test')
const { join } = require('node:path')
Expand Down Expand Up @@ -242,7 +242,7 @@ const ajv = new Ajv({
})

tests.forEach(function (testConf) {
t.test(testConf.name, t => {
test(testConf.name, t => {
const options = {
schema: testConf.schema,
data: testConf.data,
Expand Down Expand Up @@ -284,7 +284,7 @@ const strictValidator = new Ajv({
});

[noCoercionTest].forEach(function (testConf) {
t.test(testConf.name, t => {
test(testConf.name, t => {
const options = {
schema: testConf.schema,
data: testConf.data,
Expand All @@ -297,7 +297,7 @@ const strictValidator = new Ajv({
})
})

t.test('ajv enhancement', t => {
test('ajv enhancement', async t => {
t.plan(2)
const testCase = {
schema: {
Expand All @@ -317,7 +317,7 @@ t.test('ajv enhancement', t => {
}
}

t.test('return', t => {
await t.test('return', async t => {
const options = {
schema: testCase.schema,
data: testCase.data,
Expand All @@ -331,7 +331,7 @@ t.test('ajv enhancement', t => {
makeTest(t, options, testCase.isOk, testCase.confExpected)
})

t.test('no return', t => {
await t.test('no return', async t => {
const options = {
schema: testCase.schema,
data: testCase.data,
Expand Down
4 changes: 2 additions & 2 deletions test/expand.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const t = require('tap')
const { test } = require('node:test')
const makeTest = require('./make-test')
const { join } = require('node:path')

Expand Down Expand Up @@ -74,7 +74,7 @@ const tests = [
]

tests.forEach(function (testConf) {
t.test(testConf.name, t => {
test(testConf.name, t => {
const options = {
schema: testConf.schema,
data: testConf.data,
Expand Down
6 changes: 3 additions & 3 deletions test/fluent-schema.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict'

const t = require('tap')
const { test } = require('node:test')

if (parseInt(process.versions.node.split('.', 1)[0]) <= 8) {
t.skip('not supported')
test.skip('not supported')
} else {
run()
}
Expand All @@ -12,7 +12,7 @@ function run () {
const S = require('fluent-json-schema')
const makeTest = require('./make-test')

t.test('simple object - fluent-json-schema', t => {
test('simple object - fluent-json-schema', t => {
const options = {
schema: S.object().prop('PORT', S.string()),
data: {
Expand Down
6 changes: 3 additions & 3 deletions test/make-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ function makeTest (t, options, isOk, confExpected, errorMessage) {

try {
const conf = envSchema(options)
t.strictSame(conf, confExpected)
t.assert.deepStrictEqual(conf, confExpected)
} catch (err) {
if (isOk) {
t.fail(err)
t.assert.fail(err)
return
}
t.strictSame(err.message, errorMessage)
t.assert.strictEqual(err.message, errorMessage)
}
}

Expand Down
6 changes: 3 additions & 3 deletions test/no-global.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 envSchema = require('../index')

test('no globals', t => {
Expand Down Expand Up @@ -29,10 +29,10 @@ test('no globals', t => {

{
const conf = envSchema(JSON.parse(JSON.stringify(options)))
t.strictSame(conf, { MONGO_URL: 'good', PORT: 3000 })
t.assert.deepStrictEqual(conf, { MONGO_URL: 'good', PORT: 3000 })
}
{
const conf = envSchema(JSON.parse(JSON.stringify(options)))
t.strictSame(conf, { MONGO_URL: 'good', PORT: 3000 })
t.assert.deepStrictEqual(conf, { MONGO_URL: 'good', PORT: 3000 })
}
})

0 comments on commit e63ff8f

Please sign in to comment.