Repository navigation
👷 [RUM-19776] Run unit tests with Vitest (Jasmine compatibility shim) instead of Karma #5135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
4a40d6e
rename forEach file
BenoitZugmeyer 29aeddc
vitest setup
BenoitZugmeyer c309d19
♻️ adapt vitest setup to current main
thomas-lebeau e8f30f3
🚨 fix typecheck, lint and karma for the vitest setup
thomas-lebeau 901b51d
👷 declare vitest dependencies in LICENSE-3rdparty.csv
thomas-lebeau 9b6be97
👷 run unit tests with vitest instead of karma
thomas-lebeau c31ed25
⚡️ run unit test files in a shared page (isolate: false)
thomas-lebeau 4c08724
🐛 pre-bundle react/jsx-dev-runtime so Vite doesn't reload the shared …
thomas-lebeau 3835124
♻️ import noop from @datadog/js-core/util
thomas-lebeau 627a3a8
📝 update the running-tests skill for Vitest unit tests
thomas-lebeau 9945e02
👌 drop the duplicate uncaught error disabling and document the two he…
thomas-lebeau d3bece0
✅ restore the page URL after each test
thomas-lebeau 4cf72f5
👌 record Jasmine failures before throwing and check console calls aft…
thomas-lebeau 7bcfe94
👌 restore the page URL after the cleanup tasks of the test
thomas-lebeau 1261399
✅ only define prototype toJSON methods synchronously in specs
thomas-lebeau 71391be
👌 run Vitest setup files in order, cover developer-extension, documen…
thomas-lebeau 758dce0
👌 don't collect developer-extension coverage
thomas-lebeau edd8020
👌 preserve suffix matching in coverage exclusions
thomas-lebeau File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
16 changes: 15 additions & 1 deletion
16
packages/browser-core/test/disableJasmineUncaughtExceptionTracking.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,22 @@ | ||
| import { noop } from '@datadog/js-core/util' | ||
| import { registerCleanupTask } from './registerCleanupTask' | ||
|
|
||
| /** | ||
| * Disable Jasmine's uncaught error handling. This is useful for test cases throwing exceptions or | ||
| * unhandled rejections that are expected to be caught somehow, but Jasmine also catch them and | ||
| * fails the test. | ||
| * | ||
| * Replace the handler instead of spying on it, so tests can still replace `window.onerror`. Tests | ||
| * must not spy on it after calling this: Jasmine restores spies after the cleanup tasks run, so it | ||
| * would put back the disabled handler. | ||
| * | ||
| * This is the Karma implementation. When running with Vitest, this module is aliased to | ||
| * `test/unit-vitest/disableJasmineUncaughtExceptionTracking.ts` (see `test/unit-vitest/vite.config.ts`). | ||
| */ | ||
| export function disableJasmineUncaughtExceptionTracking() { | ||
| spyOn(window as any, 'onerror') | ||
| const originalOnError = window.onerror | ||
| window.onerror = noop | ||
| registerCleanupTask(() => { | ||
| window.onerror = originalOnError | ||
|
thomas-lebeau marked this conversation as resolved.
Resolved
thomas-lebeau marked this conversation as resolved.
Resolved
|
||
| }) | ||
| } | ||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.