From 8e88e30166942740faf8c5e8b2510243a811d8f4 Mon Sep 17 00:00:00 2001 From: Stephan Date: Sun, 4 Feb 2018 00:17:31 +0100 Subject: [PATCH 1/4] run Jest command in shell on Windows --- src/JestExt.ts | 6 +++++- src/helpers.ts | 6 +----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/JestExt.ts b/src/JestExt.ts index ead71522a..9abed0b45 100644 --- a/src/JestExt.ts +++ b/src/JestExt.ts @@ -1,6 +1,7 @@ import * as vscode from 'vscode' import * as path from 'path' import * as fs from 'fs' +import { platform } from 'os' import { Runner, Settings, ProjectWorkspace, JestTotalResults } from 'jest-editor-support' import { matcher } from 'micromatch' @@ -81,7 +82,10 @@ export class JestExt { } let maxRestart = 4 - this.jestProcess = new Runner(this.workspace) + // Use a shell to run Jest command on Windows in order to correctly spawn `.cmd` files + // For details see https://github.com/jest-community/vscode-jest/issues/98 + const useShell = platform() === 'win32' + this.jestProcess = new Runner(this.workspace, { shell: useShell }) this.jestProcess .on('debuggerProcessExit', () => { diff --git a/src/helpers.ts b/src/helpers.ts index 3895c2965..7475da6d4 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -15,13 +15,9 @@ export function pathToJest(pluginSettings: IPluginSettings) { const defaultPath = normalize('node_modules/.bin/jest') if (path === defaultPath && isBootstrappedWithCreateReactApp(pluginSettings.rootPath)) { // If it's the default, run the script instead - return platform() === 'win32' ? 'npm.cmd test --' : 'npm test --' + return 'npm test --' } - // For windows support, see https://github.com/jest-community/vscode-jest/issues/10 - if (!path.includes('.cmd') && platform() === 'win32') { - return path + '.cmd' - } return path } From 570bdce6876c803b3ce150c2d19f783e91f52954 Mon Sep 17 00:00:00 2001 From: Stephan Date: Sun, 4 Feb 2018 00:32:45 +0100 Subject: [PATCH 2/4] updated jest dependencies --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 331139807..76c3c059e 100644 --- a/package.json +++ b/package.json @@ -158,9 +158,9 @@ "elegant-spinner": "^1.0.1", "istanbul-lib-coverage": "^1.1.1", "istanbul-lib-source-maps": "^1.1.0", - "jest-editor-support": "^22.0.4", - "jest-snapshot": "^22.0.3", - "jest-test-typescript-parser": "^22.0.4", + "jest-editor-support": "^22.1.3", + "jest-snapshot": "^22.1.2", + "jest-test-typescript-parser": "^22.1.3", "micromatch": "^2.3.11" } } From 896bdc215b40c1eae26e053caf50545cb87c99d3 Mon Sep 17 00:00:00 2001 From: Stephan Date: Sun, 4 Feb 2018 00:39:33 +0100 Subject: [PATCH 3/4] update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94604204d..c066c774e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ Bug-fixes within the same version aren't needed --> +## Master + +* Adding `.cmd` in `pathToJest` on Windows isn't necessary anymore - stephtr + ### 2.6.0 * Adds ability to open snapshot file directly from test - bookman25 From 6b19a990b7bc2edbfc0ed2b745d170b280ccc514 Mon Sep 17 00:00:00 2001 From: Stephan Date: Tue, 20 Feb 2018 19:51:52 +0100 Subject: [PATCH 4/4] update TypeScript definition of Runner Options --- typings/jest-editor-support.d.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/typings/jest-editor-support.d.ts b/typings/jest-editor-support.d.ts index 4a3f34d33..f437038ea 100644 --- a/typings/jest-editor-support.d.ts +++ b/typings/jest-editor-support.d.ts @@ -1,5 +1,17 @@ import * as editor from 'jest-editor-support' +import { ChildProcess } from 'child_process' declare module 'jest-editor-support' { + interface SpawnOptions { + shell?: boolean + } + + interface Options { + createProcess?(workspace: ProjectWorkspace, args: string[], options?: SpawnOptions): ChildProcess + testNamePattern?: string + testFileNamePattern?: string + shell?: boolean + } + interface JestTotalResults { coverageMap: any }