Fix running tests twice when test paths are passed#2701
Merged
Conversation
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.
robertbrignull
approved these changes
Aug 14, 2023
Contributor
robertbrignull
left a comment
There was a problem hiding this comment.
It works for me locally and I'm no longer seeing double test runs.
Contributor
|
Thanks @koesie10!! 🎉 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When running tests using
--runTestsByPath <some-path>, the tests were being run twice because jest-runner-vscoderesolves test paths, 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.tswhich would cause Jest to run the tests twice. This fixes this by resolving the paths to their absolute paths, and then removing any duplicates.Checklist
ready-for-doc-reviewlabel there.