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

Fix failing tests with cross-env #639

Merged
merged 4 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"scripts": {
"lint": "standard",
"lint:fix": "standard --fix",
"unit:template-ts-esm": "TS_NODE_PROJECT=./templates/app-ts-esm/tsconfig.json tap templates/app-ts-esm/test/**/*.test.ts --no-coverage --node-arg=--loader=ts-node/esm --timeout 100",
"unit:cli": "tap \"test/**/*.test.{js,ts}\" --no-coverage --timeout 200",
"unit:templates-without-ts-esm": "tap \"templates/app/**/*.test.js\" \"templates/app-esm/**/*.test.js\" \"templates/app-ts/**/*.test.ts\" --no-coverage --timeout 200",
"unit:template-ts-esm": " cross-env TS_NODE_PROJECT=./templates/app-ts-esm/tsconfig.json tap templates/app-ts-esm/test/**/*.test.ts --no-coverage --node-arg=--loader=ts-node/esm --timeout 400 --jobs 1 --color -R specy",
"unit:cli": "tap \"test/**/*.test.{js,ts}\" --no-coverage --jobs=1 --timeout 400 --jobs 1 --color -R specy",
"unit:templates-without-ts-esm": "tap \"templates/app/**/*.test.js\" \"templates/app-esm/**/*.test.js\" \"templates/app-ts/**/*.test.ts\" --no-coverage --timeout 400 --jobs 1 --color -R specy",
"pretest": "xcopy /e /k /i . \"..\\node_modules\\fastify-cli\" || rsync -r --exclude=node_modules ./ node_modules/fastify-cli || echo 'this is fine'",
"test-no-coverage": "npm run unit:cli && npm run unit:templates-without-ts-esm && npm run unit:template-ts-esm && npm run test:typescript",
"test": "c8 --clean npm run test-no-coverage",
Expand Down Expand Up @@ -71,6 +71,7 @@
"@types/tap": "^15.0.5",
"c8": "^7.13.0",
"concurrently": "^7.0.0",
"cross-env": "^7.0.3",
"del-cli": "^3.0.1",
"fastify-tsconfig": "^1.0.1",
"minimatch": "^5.1.0",
Expand Down
6 changes: 3 additions & 3 deletions test/print-routes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test('should print routes', async t => {

await fastify.close()
t.ok(spy.called)
t.same(spy.args, [['debug', '└── / (GET)\n / (HEAD)\n / (POST)\n']])
t.same(spy.args, [['debug', '└── / (GET, HEAD, POST)\n']])
})

test('should print routes via cli', async t => {
Expand All @@ -32,7 +32,7 @@ test('should print routes via cli', async t => {
await command.cli(['./examples/plugin.js'])

t.ok(spy.called)
t.same(spy.args, [['debug', '└── / (GET)\n / (HEAD)\n / (POST)\n']])
t.same(spy.args, [['debug', '└── / (GET, HEAD, POST)\n']])
})

test('should warn on file not found', t => {
Expand Down Expand Up @@ -109,5 +109,5 @@ test('should print routes of server with an async/await plugin', async t => {

await fastify.close()
t.ok(spy.called)
t.same(spy.args, [['debug', '└── / (GET)\n / (HEAD)\n']])
t.same(spy.args, [['debug', '└── / (GET, HEAD)\n']])
})
4 changes: 2 additions & 2 deletions test/start.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ test('should start the server listening on 0.0.0.0 when running in kubernetes',
t.pass('server closed')
})

test('should start the server with watch options that the child process restart when directory changed', { skip: process.platform === 'win32' }, async (t) => {
test('should start the server with watch options that the child process restart when directory changed', { skip: process.platform === 'win32' || (process.platform === 'darwin' && ['v20', 'v19', 'v18'].some(v => process.version.startsWith(v))) }, async (t) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We skip this on windows. Can we skip on macos?

Copy link
Member

Choose a reason for hiding this comment

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

go ahead

Copy link
Member

Choose a reason for hiding this comment

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

I would prefer not to tbh, but I don't have good arguments for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll spend some time to try and debug. I don't understand what causes failure here tbh

t.plan(3)
const tmpjs = path.resolve(baseFilename + '.js')

Expand Down Expand Up @@ -584,7 +584,7 @@ test('should start the server with watch options that the child process restart
t.pass('should receive restart event')
})

test('should start the server with watch and verbose-watch options that the child process restart when directory changed with console message about changes ', { skip: process.platform === 'win32' }, async (t) => {
test('should start the server with watch and verbose-watch options that the child process restart when directory changed with console message about changes ', { skip: process.platform === 'win32' || (process.platform === 'darwin' && ['v20', 'v19', 'v18'].some(v => process.version.startsWith(v))) }, async (t) => {
t.plan(4)

const spy = sinon.spy()
Expand Down