@@ -17,3 +17,113 @@ index 0663c5c..4991663 100644
1717 const options = JSON.parse(PARENT_JEST_OPTIONS);
1818 const jestOptions = [
1919 ...options.args,
20+ diff --git a/node_modules/jest-runner-vscode/dist/public-types.d.ts b/node_modules/jest-runner-vscode/dist/public-types.d.ts
21+ index 57716e5..d8614af 100644
22+ --- a/node_modules/jest-runner-vscode/dist/public-types.d.ts
23+ +++ b/node_modules/jest-runner-vscode/dist/public-types.d.ts
24+ @@ -59,4 +59,5 @@ export interface RunnerOptions {
25+ * code, or download progress. Defaults to `false`.
26+ */
27+ quiet?: boolean;
28+ + retries?: number;
29+ }
30+ diff --git a/node_modules/jest-runner-vscode/dist/run-vscode.d.ts b/node_modules/jest-runner-vscode/dist/run-vscode.d.ts
31+ index 8657ace..4d35409 100644
32+ --- a/node_modules/jest-runner-vscode/dist/run-vscode.d.ts
33+ +++ b/node_modules/jest-runner-vscode/dist/run-vscode.d.ts
34+ @@ -16,5 +16,7 @@ export declare type RunVSCodeOptions = {
35+ onFailure: JestRunner.OnTestFailure;
36+ ipc: InstanceType<typeof IPC>;
37+ quiet?: boolean;
38+ + attempt?: number;
39+ + maxRetries?: number;
40+ };
41+ - export default function runVSCode({ vscodePath, args, jestArgs, env, tests, globalConfig, filterOutput, onStart, onResult, onFailure, ipc, quiet, }: RunVSCodeOptions): Promise<void>;
42+ + export default function runVSCode(options: RunVSCodeOptions): Promise<void>;
43+ diff --git a/node_modules/jest-runner-vscode/dist/run-vscode.js b/node_modules/jest-runner-vscode/dist/run-vscode.js
44+ index 5d8e513..7e556ee 100644
45+ --- a/node_modules/jest-runner-vscode/dist/run-vscode.js
46+ +++ b/node_modules/jest-runner-vscode/dist/run-vscode.js
47+ @@ -5,8 +5,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
48+ Object.defineProperty(exports, "__esModule", { value: true });
49+ const child_process_1 = __importDefault(require("child_process"));
50+ const console_1 = __importDefault(require("console"));
51+ - async function runVSCode({ vscodePath, args, jestArgs, env, tests, globalConfig, filterOutput, onStart, onResult, onFailure, ipc, quiet, }) {
52+ - return await new Promise(resolve => {
53+ + const fs_1 = __importDefault(require("fs"));
54+ + const path_1 = __importDefault(require("path"));
55+ + const os_1 = __importDefault(require("os"));
56+ + async function runVSCode(options) {
57+ + const { vscodePath, args, jestArgs, env, tests, globalConfig, filterOutput, onStart, onResult, onFailure, ipc, quiet, attempt, maxRetries, } = options;
58+ + const tempUserDir = await fs_1.default.promises.mkdtemp(path_1.default.resolve(os_1.default.tmpdir(), 'jest-runner-vscode-user-data-'));
59+ + return await new Promise(promiseResolve => {
60+ + const resolve = () => {
61+ + fs_1.default.rm(tempUserDir, { recursive: true }, () => {
62+ + promiseResolve();
63+ + });
64+ + };
65+ const useStdErr = globalConfig.json || globalConfig.useStderr;
66+ const log = useStdErr
67+ ? console_1.default.error.bind(console_1.default)
68+ @@ -82,7 +92,11 @@ async function runVSCode({ vscodePath, args, jestArgs, env, tests, globalConfig,
69+ ipc.server.on('stdout', onStdout);
70+ ipc.server.on('stderr', onStderr);
71+ ipc.server.on('error', onError);
72+ - const vscode = child_process_1.default.spawn(vscodePath, args, { env: environment });
73+ + const launchArgs = args;
74+ + if (!hasArg('user-data-dir', launchArgs)) {
75+ + launchArgs.push(`--user-data-dir=${tempUserDir}`);
76+ + }
77+ + const vscode = child_process_1.default.spawn(vscodePath, launchArgs, { env: environment });
78+ if (!silent && !filterOutput) {
79+ vscode.stdout.pipe(process.stdout);
80+ vscode.stderr.pipe(process.stderr);
81+ @@ -99,6 +113,29 @@ async function runVSCode({ vscodePath, args, jestArgs, env, tests, globalConfig,
82+ exited = true;
83+ const exit = code ?? signal ?? '<unknown>';
84+ const message = `VS Code exited with exit code ${exit}`;
85+ + const currentAttempt = attempt ?? 0;
86+ + const incompleteTests = tests.some(test => !completedTests.has(test));
87+ + if (maxRetries &&
88+ + maxRetries > 0 &&
89+ + currentAttempt < maxRetries &&
90+ + incompleteTests) {
91+ + silent || quiet || log(message);
92+ + const newAttempt = currentAttempt + 1;
93+ + const newTests = tests.filter(test => !completedTests.has(test));
94+ + ipc.server.off('testFileResult', onTestFileResult);
95+ + ipc.server.off('testStart', onTestStart);
96+ + ipc.server.off('testFileStart', onTestStart);
97+ + ipc.server.off('stdout', onStdout);
98+ + ipc.server.off('stderr', onStderr);
99+ + ipc.server.off('error', onError);
100+ + await runVSCode({
101+ + ...options,
102+ + tests: newTests,
103+ + attempt: newAttempt,
104+ + });
105+ + resolve();
106+ + return;
107+ + }
108+ if (typeof code !== 'number' || code !== 0) {
109+ silent || quiet || console_1.default.error(message);
110+ const error = vscodeError ?? childError ?? new Error(message);
111+ @@ -138,3 +175,6 @@ async function runVSCode({ vscodePath, args, jestArgs, env, tests, globalConfig,
112+ });
113+ }
114+ exports.default = runVSCode;
115+ + function hasArg(argName, argList) {
116+ + return argList.some(a => a === `--${argName}` || a.startsWith(`--${argName}=`));
117+ + }
118+ diff --git a/node_modules/jest-runner-vscode/dist/runner.js b/node_modules/jest-runner-vscode/dist/runner.js
119+ index e24c976..c374022 100644
120+ --- a/node_modules/jest-runner-vscode/dist/runner.js
121+ +++ b/node_modules/jest-runner-vscode/dist/runner.js
122+ @@ -107,6 +107,7 @@ class VSCodeTestRunner {
123+ onFailure,
124+ ipc,
125+ quiet: vscodeOptions.quiet,
126+ + maxRetries: vscodeOptions.retries,
127+ });
128+ }
129+ catch (error) {
0 commit comments