From ca06354b42fe9e004cbc4320d5b2a8a5483f60c9 Mon Sep 17 00:00:00 2001 From: Tim Seckinger Date: Tue, 7 May 2019 09:28:10 +0200 Subject: [PATCH] try slash to fix Windows CI --- packages/jest-core/package.json | 2 ++ .../src/__tests__/__snapshots__/watch.test.js.snap | 4 ++-- packages/jest-core/src/__tests__/watch.test.js | 11 ++++------- packages/jest-core/src/watch.ts | 3 ++- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/jest-core/package.json b/packages/jest-core/package.json index 8f7ca0c135f2..9f980af3c53d 100644 --- a/packages/jest-core/package.json +++ b/packages/jest-core/package.json @@ -31,6 +31,7 @@ "pirates": "^4.0.1", "realpath-native": "^1.1.0", "rimraf": "^2.5.4", + "slash": "^2.0.0", "strip-ansi": "^5.0.0" }, "devDependencies": { @@ -41,6 +42,7 @@ "@types/micromatch": "^3.1.0", "@types/p-each-series": "^1.0.0", "@types/rimraf": "^2.0.2", + "@types/slash": "^2.0.0", "@types/strip-ansi": "^3.0.0" }, "engines": { diff --git a/packages/jest-core/src/__tests__/__snapshots__/watch.test.js.snap b/packages/jest-core/src/__tests__/__snapshots__/watch.test.js.snap index 1a1382cec3f6..be0c72787eaa 100644 --- a/packages/jest-core/src/__tests__/__snapshots__/watch.test.js.snap +++ b/packages/jest-core/src/__tests__/__snapshots__/watch.test.js.snap @@ -51,14 +51,14 @@ Watch Usage `; exports[`Watch mode flows makes watch plugin initialization errors look nice 1`] = ` -"Error: Failed to initialize watch plugin \\"packages/jest-core/src/__tests__/__fixtures__/watch_plugin_throws\\": +[Error: Failed to initialize watch plugin "packages/jest-core/src/__tests__/__fixtures__/watch_plugin_throws": ● Test suite failed to run initialization error at Object. (__fixtures__/watch_plugin_throws.js:3:7) -" +] `; exports[`Watch mode flows shows prompts for WatchPlugins in alphabetical order 1`] = ` diff --git a/packages/jest-core/src/__tests__/watch.test.js b/packages/jest-core/src/__tests__/watch.test.js index 44742fcf76a1..358446807c64 100644 --- a/packages/jest-core/src/__tests__/watch.test.js +++ b/packages/jest-core/src/__tests__/watch.test.js @@ -579,9 +579,8 @@ describe('Watch mode flows', () => { it('makes watch plugin initialization errors look nice', async () => { const pluginPath = `${__dirname}/__fixtures__/watch_plugin_throws`; - expect.assertions(1); - try { - await watch( + await expect( + watch( { ...globalConfig, rootDir: __dirname, @@ -591,10 +590,8 @@ describe('Watch mode flows', () => { pipe, hasteMapInstances, stdin, - ); - } catch (error) { - expect(error.toString().replace(/\\/, '/')).toMatchSnapshot(); - } + ), + ).rejects.toMatchSnapshot(); }); it.each` diff --git a/packages/jest-core/src/watch.ts b/packages/jest-core/src/watch.ts index 57ed39a36b0c..5b97d1623709 100644 --- a/packages/jest-core/src/watch.ts +++ b/packages/jest-core/src/watch.ts @@ -9,6 +9,7 @@ import path from 'path'; import ansiEscapes from 'ansi-escapes'; import chalk from 'chalk'; import exit from 'exit'; +import slash from 'slash'; import HasteMap, {HasteChangeEvent} from 'jest-haste-map'; import {formatExecError} from 'jest-message-util'; import {isInteractive, preRunMessage, specialChars} from 'jest-util'; @@ -183,7 +184,7 @@ export default function watch( } catch (error) { const errorWithContext = new Error( `Failed to initialize watch plugin "${chalk.bold( - path.relative(process.cwd(), pluginWithConfig.path), + slash(path.relative(process.cwd(), pluginWithConfig.path)), )}":\n\n${formatExecError(error, contexts[0].config, { noStackTrace: false, })}`,