-
Notifications
You must be signed in to change notification settings - Fork 133
Make unit tests run in a browser #1622
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
Open
peaBerberian
wants to merge
5
commits into
dev
Choose a base branch
from
misc/vitest-browser2
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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
25327f8
to
f7d5638
Compare
f7d5638
to
e6fa6f2
Compare
d05cafc
to
c6858a6
Compare
e6fa6f2
to
d598ebd
Compare
c6858a6
to
8bed678
Compare
d598ebd
to
b311011
Compare
8bed678
to
5876dd2
Compare
c1519dc
to
79b04e5
Compare
5876dd2
to
5661c8b
Compare
0c9775a
to
68ec707
Compare
68ec707
to
049153c
Compare
049153c
to
747a27d
Compare
? Automated performance checks have passed on commit DetailsPerformance tests 1st run outputNo significative change in performance for tests:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
This mega-PR rewrites unit tests so they can be run in a web browser (for now Chrome + Firefox), through
webdriverio
- just like our integration and memory tests.This allows us to run unit tests in the actual environment where the RxPlayer will run and to have a common script + environment for unit, integration and memory tests, thus simplifying the project.
The main difficulty was linked to our over-reliance on
vitest
'sdoMock
+importActual
functions, the second which has a different behavior when run in a web browser: multipleimportActual
calls in the same test file won't re-evaluate that imported file. This means thatdoMock
performed in-betweenimportActual
calls for the same file won't have an impact on that file.This might be fixed in the future, but I wanted to see how most people succeeded to run
vitest
in a browser. It seems that relying on a top-levelmock
function is much more idiomatic, while relying on thehoisted
function to also declare hoisted mocks whose implementation can change in-between tests.Though, to ensure portability between test frameworks if we ever change it (JavaScript is like that sometimes), I try to limit reliance on that
vitest
-specificvi.mock
/vi.hoisted
concept, by prefering just mocking through only the more portablespyOn
when possible.