From eaa2dc3edb50430dea1c6c7fc47fd168580a92b8 Mon Sep 17 00:00:00 2001 From: Bret Comnes <166301+bcomnes@users.noreply.github.com> Date: Tue, 18 Jul 2023 11:50:48 -0700 Subject: [PATCH] Fix failing tests with cross-env (#639) --- package.json | 7 ++++--- test/print-routes.test.js | 6 +++--- test/start.test.js | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index ee956fb3..c38966e1 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/test/print-routes.test.js b/test/print-routes.test.js index 42ccd851..02789257 100644 --- a/test/print-routes.test.js +++ b/test/print-routes.test.js @@ -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 => { @@ -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 => { @@ -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']]) }) diff --git a/test/start.test.js b/test/start.test.js index 4cabb039..ed29fbc1 100644 --- a/test/start.test.js +++ b/test/start.test.js @@ -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) => { t.plan(3) const tmpjs = path.resolve(baseFilename + '.js') @@ -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()