Skip to content

Commit

Permalink
Switch unit tests to use vitest (#1445)
Browse files Browse the repository at this point in the history
* create a globalSetup for vitest

* rename tests files to .test.js

* delete useless files and lint

* skip problematic test on firefox

* fix

* skip test

* [WIP] Switch unit tests to use vitest

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/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).

* Add test:unit:watch

* tests: Fix and work around remaining unit test issues

* wip

* Reorder checks in often-failing integration test

* Try to '''fix''' memory tests

---------

Co-authored-by: Florent <[email protected]>
  • Loading branch information
peaBerberian and Florent-Bouisset authored Jun 17, 2024
1 parent 6be1683 commit 5794201
Show file tree
Hide file tree
Showing 216 changed files with 15,778 additions and 24,091 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 5794201

Please sign in to comment.