Skip to content

Commit

Permalink
Merge branch 'master' into test-node-builtin
Browse files Browse the repository at this point in the history
  • Loading branch information
big-kahuna-burger authored Dec 2, 2023
2 parents d305d3f + 957bd8d commit 9fe5443
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 6 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
"unit:ts-esm": "cross-env TS_NODE_PROJECT=./templates/app-ts-esm/tsconfig.json FASTIFY_AUTOLOAD_TYPESCRIPT=1 node -r tsx/cjs --import tsx/esm suite-runner.js \"templates/app-ts-esm/test/**/*.test.ts\"",
"unit:suites": "node should-skip-test-suites.js || npm run all-suites",
"all-suites": "npm run unit:cjs && npm run unit:esm && npm run unit:ts-cjs && npm run unit:ts-esm",
"unit:cli": "tap \"test/**/*.test.js\" --no-coverage --timeout 400 --jobs 1 --color -R specy",
"unit:cli-js": "tap \"test/**/*.test.js\" --no-coverage --timeout 400 --jobs 1 --color -R specy",
"unit:cli-ts": "cross-env TS_NODE_PROJECT=./test/configs/ts-cjs.tsconfig.json tap \"test/**/*.test.ts\" --no-coverage --timeout 400 --jobs 1 --color -R specy",
"unit:cli": "npm run unit:cli-js && npm run unit:cli-ts",
"test:cli-and-typescript": "npm run unit:cli && npm run test:typescript",
"test:typescript": "tsd templates/plugin -t ./../../index.d.ts && tsc --project templates/app-ts/tsconfig.json && del-cli templates/app-ts/dist"
},
Expand Down
8 changes: 8 additions & 0 deletions test/configs/ts-cjs.tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../../node_modules/fastify-tsconfig/tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"sourceMap": true
},
"include": ["src/**/*.ts"]
}
12 changes: 12 additions & 0 deletions test/configs/ts-esm.tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../../node_modules/fastify-tsconfig/tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"sourceMap": true,
"moduleResolution": "NodeNext",
"module": "NodeNext",
"target": "ES2022",
"esModuleInterop": true
},
"include": ["src/**/*.ts"]
}
13 changes: 9 additions & 4 deletions test/print-plugins.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ const printPlugins = require('../print-plugins')

const test = tap.test

test('should print plugins', async t => {
const { NYC_PROCESS_ID, NODE_V8_COVERAGE } = process.env
const SHOULD_SKIP = NYC_PROCESS_ID || NODE_V8_COVERAGE

// This test should be skipped when coverage reporting is used since outputs won't match
test('should print plugins', { skip: SHOULD_SKIP }, async t => {
t.plan(3)

const spy = sinon.spy()
Expand All @@ -25,8 +29,8 @@ test('should print plugins', async t => {
t.match(spy.args[0][1], /bound root \d+ ms\n├── bound _after \d+ ms\n├─┬ function \(fastify, options, next\) { -- fastify\.decorate\('test', true\) \d+ ms\n│ ├── bound _after \d+ ms\n│ ├── bound _after \d+ ms\n│ └── bound _after \d+ ms\n└── bound _after \d+ ms\n/)
})

// This never exits in CI for some reason
test('should plugins routes via cli', { skip: process.env.CI }, async t => {
// This test should be skipped when coverage reporting is used since outputs won't match
test('should plugins routes via cli', { skip: SHOULD_SKIP }, async t => {
t.plan(1)
const { stdout } = await exec('node cli.js print-plugins ./examples/plugin.js', { encoding: 'utf-8', timeout: 10000 })
t.match(
Expand Down Expand Up @@ -91,7 +95,8 @@ test('should exit without error on help', t => {
t.end()
})

test('should print plugins of server with an async/await plugin', async t => {
// This test should be skipped when coverage reporting is used since outputs won't match
test('should print plugins of server with an async/await plugin', { skip: SHOULD_SKIP }, async t => {
const nodeMajorVersion = process.versions.node.split('.').map(x => parseInt(x, 10))[0]
if (nodeMajorVersion < 7) {
t.pass('Skip because Node version < 7')
Expand Down
4 changes: 3 additions & 1 deletion test/print-routes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const exec = util.promisify(require('node:child_process').exec)
const printRoutes = require('../print-routes')

const test = tap.test
const { NYC_PROCESS_ID, NODE_V8_COVERAGE } = process.env
const SHOULD_SKIP = NYC_PROCESS_ID || NODE_V8_COVERAGE

test('should print routes', async t => {
t.plan(2)
Expand All @@ -25,7 +27,7 @@ test('should print routes', async t => {
})

// This never exits in CI for some reason
test('should print routes via cli', { skip: process.env.CI }, async t => {
test('should print routes via cli', { skip: SHOULD_SKIP }, async t => {
t.plan(1)
const { stdout } = await exec('node cli.js print-routes ./examples/plugin.js', { encoding: 'utf-8', timeout: 10000 })
t.same(
Expand Down

0 comments on commit 9fe5443

Please sign in to comment.