Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: #5555 - move to node test runner #440

Merged
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
f45a705
test: forceEsm from tap to node test runner
SamSalvatico Jan 14, 2025
1280440
test: updated test/typescript/basic.ts
SamSalvatico Jan 15, 2025
a754488
test: updated test/commonjs/autohooks-basic.js
SamSalvatico Jan 15, 2025
3a4c5d6
test: updated test/commonjs/autohooks-*.js
SamSalvatico Jan 15, 2025
ab32e9d
test: updated test/commonjs/babel-node.js and basic.js
SamSalvatico Jan 17, 2025
19adc59
test: updated cyclic
SamSalvatico Jan 17, 2025
e51ee0d
test: updated deep
SamSalvatico Jan 17, 2025
c0120d3
test: updated dependency
SamSalvatico Jan 17, 2025
e76d97c
test: updated commonjs/error
SamSalvatico Jan 17, 2025
aba67ed
test: updated graph-dependency
SamSalvatico Jan 17, 2025
3f67a45
test: updated commonjs/index-package.js
SamSalvatico Jan 17, 2025
f8ffbd3
test: updated commonjs/non-plugin.js
SamSalvatico Jan 17, 2025
88a1c72
test: updated commonjs/options.js
SamSalvatico Jan 17, 2025
a605644
test: updated commonjs/route-parametrs.js
SamSalvatico Jan 17, 2025
fe23056
test: use promises in forceEsm
SamSalvatico Jan 17, 2025
f5740b7
test: removed assert if error after promises
SamSalvatico Jan 17, 2025
371acca
test: removed nested suites
SamSalvatico Jan 17, 2025
54bd5e8
test: updated issue 369
SamSalvatico Jan 18, 2025
cf0c1d3
test: updated issue 374
SamSalvatico Jan 18, 2025
71a6660
test: updated issue 376
SamSalvatico Jan 18, 2025
d6f90b3
Merge branch 'master' into test/5555-move-to-node-test-runner
SamSalvatico Jan 18, 2025
84a2ea3
Revert "test: updated issue 376"
SamSalvatico Jan 18, 2025
6d55f55
test: updated issue 376
SamSalvatico Jan 18, 2025
0c8c652
test: updated issue 388
SamSalvatico Jan 18, 2025
63a3422
test: updated module/autohooks
SamSalvatico Jan 18, 2025
91b6645
test: updated module/basic
SamSalvatico Jan 18, 2025
a21aeb6
test: updated module/dependency
SamSalvatico Jan 18, 2025
aedd7eb
test: updated module/route-parameters
SamSalvatico Jan 18, 2025
aa22d4b
test: updated module/index-package
SamSalvatico Jan 18, 2025
542ae9a
test: updated module/options
SamSalvatico Jan 18, 2025
12ff679
test: fixed /route-parameters
SamSalvatico Jan 18, 2025
6e403dc
test: updated module/esm-import
SamSalvatico Jan 18, 2025
c6c55c9
chore: removed tap from package.json
SamSalvatico Jan 20, 2025
595b08d
test: added glob to make windows able to expand patterns
SamSalvatico Jan 20, 2025
3eab5ae
test: try using fast-glob instead of glob
SamSalvatico Jan 20, 2025
66e6abd
test: use borp instead of fast-glob script
SamSalvatico Jan 26, 2025
50499b1
test: readded coverage
SamSalvatico Jan 27, 2025
a4e5cb2
test: added check on code coverage
SamSalvatico Jan 28, 2025
34d752e
chore: newline
SamSalvatico Jan 31, 2025
2418ee3
test: resolved conflicts
SamSalvatico Jan 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .borp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
files:
- 'test/issues/*/test.js'
- 'test/commonjs/*.js'
- 'test/module/*.js'
SamSalvatico marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 0 additions & 4 deletions .taprc

This file was deleted.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
"typescript:esbuild": "node scripts/unit-typescript-esbuild.js",
"typescript:vitest": "vitest run",
"typescript:vitest:dev": "vitest",
"unit": "node scripts/unit.js",
"unit:with-modules": "tap plugin rm @tapjs/typescript && tap plugin list && tap build && tap test/issues/*/test.js test/commonjs/*.js test/module/*.js"
"unit": "borp -C --check-coverage --lines 100 --reporter=@jsumners/line-reporter"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -75,19 +74,19 @@
"devDependencies": {
"@fastify/pre-commit": "^2.1.0",
"@fastify/url-data": "^6.0.0",
"@jsumners/line-reporter": "^1.0.1",
"@swc-node/register": "^1.9.1",
"@swc/core": "^1.5.25",
"@types/jest": "^29.5.12",
"@types/node": "^22.0.0",
"@types/tap": "^18.0.0",
"borp": "^0.19.0",
"esbuild": "^0.24.0",
"esbuild-register": "^3.5.0",
"eslint": "^9.17.0",
"fastify": "^5.0.0",
"fastify-plugin": "^5.0.0",
"jest": "^29.7.0",
"neostandard": "^0.12.0",
"tap": "^19.0.2",
"ts-jest": "^29.1.4",
"ts-node": "^10.9.2",
"ts-node-dev": "^2.0.0",
Expand Down
9 changes: 4 additions & 5 deletions scripts/unit-typescript-esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
const { exec } = require('node:child_process')

const args = [
'tap',
'--node-arg=--loader=ts-node/esm',
'--node-arg=--experimental-specifier-resolution=node',
'--disable-coverage',
'--allow-empty-coverage',
'node',
'--loader=ts-node/esm',
'--experimental-specifier-resolution=node',
'--test',
'test/typescript-esm/*.ts'
]

Expand Down
1 change: 1 addition & 0 deletions scripts/unit-typescript-tsm.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const { exec } = require('node:child_process')
const args = [
'node',
'--require=tsm',
'--test',
'test/typescript/basic.ts'
]

Expand Down
9 changes: 0 additions & 9 deletions scripts/unit.js
Copy link
Contributor Author

@SamSalvatico SamSalvatico Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am having some problems running tests using patterns, because windows is not managing them automatically
Before, when using tap, I think it was using the glob on which the library depends

I tried using the glob library by myself, but it failed.
The last idea I have is trying with fast-glob, but if it doesn't work I have to ask: do you have any clue about this?

Copy link
Contributor

@jean-michelet jean-michelet Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried using the glob library by myself, but it failed.

The link you are sharing is not a failure, this test suite has been cancelled because the Node 20 on latest MacOS failed: https://github.com/fastify/fastify-autoload/actions/runs/12870529340/job/35882162556

"Exceeded timeout of 30000 ms for a test.

This is a timeout failure we had for a long time with Jest, I am not even sure we fixed it since.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was deleted.

61 changes: 28 additions & 33 deletions test/commonjs/autohooks-basic.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,46 @@
'use strict'

const t = require('tap')
const { after, before, describe, it } = require('node:test')
const assert = require('node:assert')
const Fastify = require('fastify')

t.plan(13)

const app = Fastify()

app.register(require('./autohooks/basic'))
app.decorateRequest('hooked', '')
describe('Node test suite for autohooks-basic', function () {
const app = Fastify()
before(async function () {
app.register(require('./autohooks/basic'))
app.decorateRequest('hooked', '')
await app.ready()
})

app.ready(function (err) {
t.error(err)
after(async function () {
await app.close()
})

app.inject({
url: '/'
}, function (err, res) {
t.error(err)
it('should respond correctly to /', async function () {
const res = await app.inject({ url: '/' })

t.equal(res.statusCode, 200)
t.same(JSON.parse(res.payload), { hooked: ['root'] })
assert.strictEqual(res.statusCode, 200)
assert.deepStrictEqual(JSON.parse(res.payload), { hooked: ['root'] })
})

app.inject({
url: '/child'
}, function (err, res) {
t.error(err)
it('should respond correctly to /child', async function () {
const res = await app.inject({ url: '/child' })

t.equal(res.statusCode, 200)
t.same(JSON.parse(res.payload), { hooked: ['child'] })
assert.strictEqual(res.statusCode, 200)
assert.deepStrictEqual(JSON.parse(res.payload), { hooked: ['child'] })
})

app.inject({
url: '/child/grandchild'
}, function (err, res) {
t.error(err)
it('should respond correctly to /child/grandchild', async function () {
const res = await app.inject({ url: '/child/grandchild' })

t.equal(res.statusCode, 200)
t.same(JSON.parse(res.payload), { hooked: ['grandchild'] })
assert.strictEqual(res.statusCode, 200)
assert.deepStrictEqual(JSON.parse(res.payload), { hooked: ['grandchild'] })
})

app.inject({
url: '/sibling'
}, function (err, res) {
t.error(err)
it('should respond correctly to /sibling', async function () {
const res = await app.inject({ url: '/sibling' })

t.equal(res.statusCode, 200)
t.same(JSON.parse(res.payload), { hooked: '' })
assert.strictEqual(res.statusCode, 200)
assert.deepStrictEqual(JSON.parse(res.payload), { hooked: '' })
})
})
61 changes: 28 additions & 33 deletions test/commonjs/autohooks-cascade.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,46 @@
'use strict'

const t = require('tap')
const { after, before, describe, it } = require('node:test')
const assert = require('node:assert')
const Fastify = require('fastify')

t.plan(13)

const app = Fastify()

app.register(require('./autohooks/cascade'))
app.decorateRequest('hooked', '')
describe('Node test suite for autohooks-cascade', function () {
const app = Fastify()
before(async function () {
app.register(require('./autohooks/cascade'))
app.decorateRequest('hooked', '')
await app.ready()
})

app.ready(function (err) {
t.error(err)
after(async function () {
await app.close()
})

app.inject({
url: '/'
}, function (err, res) {
t.error(err)
it('should respond correctly to /', async function () {
const res = await app.inject({ url: '/' })

t.equal(res.statusCode, 200)
t.same(JSON.parse(res.payload), { hooked: ['root'] })
assert.strictEqual(res.statusCode, 200)
assert.deepStrictEqual(JSON.parse(res.payload), { hooked: ['root'] })
})

app.inject({
url: '/child'
}, function (err, res) {
t.error(err)
it('should respond correctly to /child', async function () {
const res = await app.inject({ url: '/child' })

t.equal(res.statusCode, 200)
t.same(JSON.parse(res.payload), { hooked: ['root', 'child'] })
assert.strictEqual(res.statusCode, 200)
assert.deepStrictEqual(JSON.parse(res.payload), { hooked: ['root', 'child'] })
})

app.inject({
url: '/child/grandchild'
}, function (err, res) {
t.error(err)
it('should respond correctly to /child/grandchild', async function () {
const res = await app.inject({ url: '/child/grandchild' })

t.equal(res.statusCode, 200)
t.same(JSON.parse(res.payload), { hooked: ['root', 'child', 'grandchild'] })
assert.strictEqual(res.statusCode, 200)
assert.deepStrictEqual(JSON.parse(res.payload), { hooked: ['root', 'child', 'grandchild'] })
})

app.inject({
url: '/sibling'
}, function (err, res) {
t.error(err)
it('should respond correctly to /sibling', async function () {
const res = await app.inject({ url: '/sibling' })

t.equal(res.statusCode, 200)
t.same(JSON.parse(res.payload), { hooked: ['root'] })
assert.strictEqual(res.statusCode, 200)
assert.deepStrictEqual(JSON.parse(res.payload), { hooked: ['root'] })
})
})
61 changes: 28 additions & 33 deletions test/commonjs/autohooks-disabled.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,46 @@
'use strict'

const t = require('tap')
const { after, before, describe, it } = require('node:test')
const assert = require('node:assert')
const Fastify = require('fastify')

t.plan(13)

const app = Fastify()

app.register(require('./autohooks/disabled'))
app.decorateRequest('hooked', 'disabled')
describe('Node test suite for autohooks-disabled', function () {
const app = Fastify()
before(async function () {
app.register(require('./autohooks/disabled'))
app.decorateRequest('hooked', 'disabled')
await app.ready()
})

app.ready(function (err) {
t.error(err)
after(async function () {
await app.close()
})

app.inject({
url: '/'
}, function (err, res) {
t.error(err)
it('should respond correctly to /', async function () {
const res = await app.inject({ url: '/' })

t.equal(res.statusCode, 200)
t.same(JSON.parse(res.payload), { hooked: 'disabled' })
assert.strictEqual(res.statusCode, 200)
assert.deepStrictEqual(JSON.parse(res.payload), { hooked: 'disabled' })
})

app.inject({
url: '/child'
}, function (err, res) {
t.error(err)
it('should respond correctly to /child', async function () {
const res = await app.inject({ url: '/child' })

t.equal(res.statusCode, 200)
t.same(JSON.parse(res.payload), { hooked: 'disabled' })
assert.strictEqual(res.statusCode, 200)
assert.deepStrictEqual(JSON.parse(res.payload), { hooked: 'disabled' })
})

app.inject({
url: '/child/grandchild'
}, function (err, res) {
t.error(err)
it('should respond correctly to /child/grandchild', async function () {
const res = await app.inject({ url: '/child/grandchild' })

t.equal(res.statusCode, 200)
t.same(JSON.parse(res.payload), { hooked: 'disabled' })
assert.strictEqual(res.statusCode, 200)
assert.deepStrictEqual(JSON.parse(res.payload), { hooked: 'disabled' })
})

app.inject({
url: '/sibling'
}, function (err, res) {
t.error(err)
it('should respond correctly to /sibling', async function () {
const res = await app.inject({ url: '/sibling' })

t.equal(res.statusCode, 200)
t.same(JSON.parse(res.payload), { hooked: 'disabled' })
assert.strictEqual(res.statusCode, 200)
assert.deepStrictEqual(JSON.parse(res.payload), { hooked: 'disabled' })
})
})
61 changes: 28 additions & 33 deletions test/commonjs/autohooks-overwrite.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,46 @@
'use strict'

const t = require('tap')
const { after, before, describe, it } = require('node:test')
const assert = require('node:assert')
const Fastify = require('fastify')

t.plan(13)

const app = Fastify()

app.register(require('./autohooks/overwrite'))
app.decorateRequest('hooked', '')
describe('Node test suite for autohooks-overwrite', function () {
const app = Fastify()
before(async function () {
app.register(require('./autohooks/overwrite'))
app.decorateRequest('hooked', '')
await app.ready()
})

app.ready(function (err) {
t.error(err)
after(async function () {
await app.close()
})

app.inject({
url: '/'
}, function (err, res) {
t.error(err)
it('should respond correctly to /', async function () {
const res = await app.inject({ url: '/' })

t.equal(res.statusCode, 200)
t.same(JSON.parse(res.payload), { hooked: ['root'] })
assert.strictEqual(res.statusCode, 200)
assert.deepStrictEqual(JSON.parse(res.payload), { hooked: ['root'] })
})

app.inject({
url: '/child'
}, function (err, res) {
t.error(err)
it('should respond correctly to /child', async function () {
const res = await app.inject({ url: '/child' })

t.equal(res.statusCode, 200)
t.same(JSON.parse(res.payload), { hooked: ['child'] })
assert.strictEqual(res.statusCode, 200)
assert.deepStrictEqual(JSON.parse(res.payload), { hooked: ['child'] })
})

app.inject({
url: '/child/grandchild'
}, function (err, res) {
t.error(err)
it('should respond correctly to /child/grandchild', async function () {
const res = await app.inject({ url: '/child/grandchild' })

t.equal(res.statusCode, 200)
t.same(JSON.parse(res.payload), { hooked: ['grandchild'] })
assert.strictEqual(res.statusCode, 200)
assert.deepStrictEqual(JSON.parse(res.payload), { hooked: ['grandchild'] })
})

app.inject({
url: '/sibling'
}, function (err, res) {
t.error(err)
it('should respond correctly to /sibling', async function () {
const res = await app.inject({ url: '/sibling' })

t.equal(res.statusCode, 200)
t.same(JSON.parse(res.payload), { hooked: ['root'] })
assert.strictEqual(res.statusCode, 200)
assert.deepStrictEqual(JSON.parse(res.payload), { hooked: ['root'] })
})
})
Loading
Loading