Skip to content

Fix running tests twice when test paths are passed#2701

Merged
koesie10 merged 1 commit intomainfrom
koesie10/fix-duplicate-test-running
Aug 14, 2023
Merged

Fix running tests twice when test paths are passed#2701
koesie10 merged 1 commit intomainfrom
koesie10/fix-duplicate-test-running

Conversation

@koesie10
Copy link
Copy Markdown
Member

When running tests using --runTestsByPath <some-path>, the tests were being run twice because jest-runner-vscode
resolves 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.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.

Checklist

  • CHANGELOG.md has been updated to incorporate all user visible changes made by this pull request.
  • Issues have been created for any UI or other user-facing changes made by this pull request.
  • [Maintainers only] If this pull request makes user-facing changes that require documentation changes, open a corresponding docs pull request in the github/codeql repo and add the ready-for-doc-review label there.

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.
@koesie10 koesie10 marked this pull request as ready for review August 14, 2023 09:08
@koesie10 koesie10 requested a review from a team as a code owner August 14, 2023 09:08
@koesie10 koesie10 requested a review from a team August 14, 2023 09:39
Copy link
Copy Markdown
Contributor

@robertbrignull robertbrignull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works for me locally and I'm no longer seeing double test runs.

@koesie10 koesie10 merged commit a46209b into main Aug 14, 2023
@koesie10 koesie10 deleted the koesie10/fix-duplicate-test-running branch August 14, 2023 11:28
@norascheuch
Copy link
Copy Markdown
Contributor

Thanks @koesie10!! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants