Skip to content

Commit

Permalink
[WIP] Switch unit tests to use vitest
Browse files Browse the repository at this point in the history
To extrapolate on #1444, this PR shows how it would look like to switch
from relying on Jest to rely on vitest for our unit tests.

The end goal being to simplify our codebase by relying on a single
testing framework.

---

I only done so for testing files in the `src/compat` directory in this
demo. It can be tested right now by calling `npm run test:unit:vitest`.

---

Sadly for now, we are still forced to rely on a JSDom-ed Node.js
environment for unit tests and a browser environment for integration
tests - meaning we have very different configs for both.

This is because we want to mock imported files in unit tests - something
that is not possible for now in browser environment through vitest
(though vitest-dev/vitest#5765 seems to have
been merged very recently so maybe we could rely on the browser for both
soon), yet we want to replicate as much as a real browser as possible in
our integration tests (because we're also testing that media playback on the
tested browsers goes as expected).
  • Loading branch information
peaBerberian committed Jun 4, 2024
1 parent 2537b4d commit 4d7daef
Show file tree
Hide file tree
Showing 194 changed files with 14,382 additions and 21,116 deletions.
4 changes: 1 addition & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,7 @@ module.exports = {
"import/no-deprecated": "error",
"import/no-extraneous-dependencies": [
"error",
{
devDependencies: false,
},
{ devDependencies: ["**/*.test.ts", "**/__tests__/**"] },
],
"import/no-internal-modules": "off",
"import/order": [
Expand Down
4 changes: 1 addition & 3 deletions FILES.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,7 @@ The rx-player contains multiple type of tests:
- unit tests: test specific parts of the code. The main goal here is to check the
implementation of smaller units of code.

They are written alongside the code, in `__tests__` directories. All its configuration
can be found at the root of the project, in `jest.config.js` (we use the jest library
for unit tests).
They are written alongside the code, in `__tests__` directories.

- memory tests: test the memory usage of the player.

Expand Down
29 changes: 0 additions & 29 deletions jest.config.js

This file was deleted.

Loading

0 comments on commit 4d7daef

Please sign in to comment.