Skip to content

Commit 1b0bcb3

Browse files
committed
Fix running tests twice when test paths are passed
When running tests using `--runTestsByPath <some-path>`, the tests were being run twice because jest-runner-vscode [resolves test paths](https://github.com/adalinesimonian/jest-runner-vscode/blob/0c98dc12adac536a200e836b77e186b8c2ba8326/packages/jest-runner-vscode/src/runner.ts#L57-L66), while the original arguments were also still passed to Jest. So, the arguments Jest would receive would look something like `test/vscode-tests/no-workspace/databases/local-databases/locations.test.ts /Users/koesie10/github/vscode-codeql/extensions/ql-vscode/test/vscode-tests/no-workspace/databases/local-databases/locations.test.ts` which would cause Jest to run the tests twice. This fixes this by resolving the paths to their absolute paths, and then removing any duplicates.
1 parent 3b7f7e5 commit 1b0bcb3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

extensions/ql-vscode/patches/jest-runner-vscode+3.0.1.patch

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ index 1ac28d5..f91f216 100644
2525
await super.setup();
2626
await (0, load_pnp_1.default)();
2727
diff --git a/node_modules/jest-runner-vscode/dist/child/runner.js b/node_modules/jest-runner-vscode/dist/child/runner.js
28-
index 0663c5c..4991663 100644
28+
index 0663c5c..bdf4a8b 100644
2929
--- a/node_modules/jest-runner-vscode/dist/child/runner.js
3030
+++ b/node_modules/jest-runner-vscode/dist/child/runner.js
3131
@@ -18,10 +18,13 @@ async function run() {
@@ -43,6 +43,16 @@ index 0663c5c..4991663 100644
4343
const options = JSON.parse(PARENT_JEST_OPTIONS);
4444
const jestOptions = [
4545
...options.args,
46+
@@ -39,6 +42,9 @@ async function run() {
47+
...(argv.projects?.map(project => path_1.default.resolve(project)) || []),
48+
options.workspacePath,
49+
]);
50+
+ const testPaths = new Set(argv._.map(testPath => path_1.default.resolve(testPath)));
51+
+ argv._ = [...testPaths];
52+
+
53+
await (0, core_1.runCLI)(argv, [...projects]);
54+
}
55+
catch (error) {
4656
diff --git a/node_modules/jest-runner-vscode/dist/public-types.d.ts b/node_modules/jest-runner-vscode/dist/public-types.d.ts
4757
index 57716e5..d8614af 100644
4858
--- a/node_modules/jest-runner-vscode/dist/public-types.d.ts

0 commit comments

Comments
 (0)