Skip to content
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

[code-infra] vitest browser & jsdom modes #14508

Open
wants to merge 320 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
320 commits
Select commit Hold shift + click to select a range
4497dd8
remove unused clock var
JCQuintas Oct 9, 2024
6539759
make test work in vitest and mocha
JCQuintas Oct 9, 2024
b20b1bb
sequence.hooks = list
JCQuintas Oct 11, 2024
840c4b6
Fix datepickes pro test
JCQuintas Oct 11, 2024
6db68b8
ignore failing browser tests
JCQuintas Oct 11, 2024
9f6f828
add lib alias config
JCQuintas Oct 11, 2024
a353cb6
init data-grid and replace skips
JCQuintas Oct 11, 2024
1885222
fix toerror
JCQuintas Oct 11, 2024
f985554
datagrid cleanup
JCQuintas Oct 11, 2024
b869545
fix jsdom issues
JCQuintas Oct 11, 2024
739c2d4
fix browser tests datagrid
JCQuintas Oct 11, 2024
8b38fd9
datagrid pro skips
JCQuintas Oct 11, 2024
f5493b8
Fix weird prop logic
JCQuintas Oct 11, 2024
820bbd5
Also change rendereditcell
JCQuintas Oct 11, 2024
8342499
refactor row editing
JCQuintas Oct 11, 2024
163ed7e
fix jsdom specific logic for vitest
JCQuintas Oct 11, 2024
953059d
fix issues with playwright scrollbar
JCQuintas Oct 11, 2024
dac3923
Revert "fix issues with playwright scrollbar"
JCQuintas Oct 14, 2024
ddc252d
update headless config to show scrollbar
JCQuintas Oct 14, 2024
8d28a7b
fix static analysis
JCQuintas Oct 14, 2024
1d47d30
Merge commit '5b4890961904b946bb7dccfd26b5e44b016d88e7' into vitest-x…
JCQuintas Oct 14, 2024
0e13811
try different config
JCQuintas Oct 14, 2024
88378a6
Merge commit '9c563ef908a49b40511201c55e7c002f9db98d51' into vitest-x…
JCQuintas Oct 14, 2024
d32bfe5
use different values for vitest and karma
JCQuintas Oct 14, 2024
dd40b0e
initial data-grid-premium
JCQuintas Oct 14, 2024
0bba870
remove unnecessary cleanup
JCQuintas Oct 14, 2024
f06ff48
use user events
JCQuintas Oct 14, 2024
5c57167
fix access
JCQuintas Oct 14, 2024
c264163
enable treeview and skips
JCQuintas Oct 14, 2024
a1feb9b
fix treeview
JCQuintas Oct 14, 2024
3615198
enable treeview pro
JCQuintas Oct 14, 2024
8757aa4
rename setup file
JCQuintas Oct 14, 2024
9799824
update mui-internals and dedupe
JCQuintas Oct 14, 2024
ed6dbb8
fix tests
JCQuintas Oct 14, 2024
7c62bfc
update comments
JCQuintas Oct 14, 2024
4f6b9c4
jsdom only packages
JCQuintas Oct 14, 2024
5442abd
setup circleci and enable coverage
JCQuintas Oct 15, 2024
aba0b63
dedupe
JCQuintas Oct 15, 2024
5a930f1
make helper libs also testable under vitest
JCQuintas Oct 15, 2024
8066b23
fix x-charts-vendor should import from esm
JCQuintas Oct 15, 2024
3bc1fa7
Merge commit 'c1e882ce9832b2a52a9d620a1d8b70a3dbad3059' into vitest-x…
JCQuintas Oct 15, 2024
98013ae
run coverage in vitest gha
JCQuintas Oct 15, 2024
f3b6d1f
add to workflow
JCQuintas Nov 5, 2024
7cf9c69
apply glob suggestions
JCQuintas Nov 5, 2024
0098dbc
Merge commit 'f50938c40ac76dba7a02ea883c54b685c9503a74' into vitest-x…
JCQuintas Nov 5, 2024
fa96d91
Merge commit 'c41bfaa2ec5ac8412b30b506bff0208fffedb3f0' into vitest-x…
JCQuintas Nov 5, 2024
0085b9e
dedupe
JCQuintas Nov 5, 2024
121bde4
fix skipping new tests
JCQuintas Nov 5, 2024
dd2621b
Revert user events for some date pickers
JCQuintas Nov 5, 2024
fd39e32
try to optimize threads
JCQuintas Nov 6, 2024
a154440
fix run
JCQuintas Nov 6, 2024
10523ec
simpler reporter
JCQuintas Nov 6, 2024
96d1d12
reporters
JCQuintas Nov 6, 2024
d86d6cf
try not using image
JCQuintas Nov 6, 2024
9d486d6
Merge commit '941f15d056549773572a5abea6023421cfafdc3b' into vitest-x…
JCQuintas Nov 6, 2024
3bfdce8
remove "browser" tag
JCQuintas Nov 6, 2024
73b10fe
try a single fork in browser mode
JCQuintas Nov 6, 2024
be83e61
threads
JCQuintas Nov 6, 2024
1ff3ea1
try options
JCQuintas Nov 7, 2024
1da790d
Merge commit '706186588abf34b75dc843e7575f17d9de54a643' into vitest-x…
JCQuintas Nov 7, 2024
6a5056e
run only one
JCQuintas Nov 7, 2024
ee14aa5
more threads
JCQuintas Nov 7, 2024
9b4e396
Apply suggestions from code review
JCQuintas Nov 14, 2024
1d38796
Merge commit 'e9c13ba43f7200a22f06e8b1d7063f31594d09b1' into vitest-x…
JCQuintas Nov 14, 2024
0bfd396
code review
JCQuintas Nov 14, 2024
4788163
use bigger class executor
JCQuintas Nov 14, 2024
ff510c2
dedupe
JCQuintas Nov 14, 2024
e5859c4
fix issues
JCQuintas Nov 14, 2024
0ac9091
Merge branch 'master' into vitest-x-browser-working
JCQuintas Nov 14, 2024
10d594d
revert thread usage
JCQuintas Nov 14, 2024
ed4e45c
update vitest and dedupe
JCQuintas Nov 14, 2024
8143ff0
update renovate
JCQuintas Nov 15, 2024
6145ec0
update configs and test
JCQuintas Nov 15, 2024
6137a65
stop using core setupVitest
JCQuintas Nov 15, 2024
2501941
try limiting mem size
JCQuintas Nov 15, 2024
0daad6b
dedupe
JCQuintas Nov 15, 2024
ab3517c
Merge commit '485054067c53685ca72a8c86c8bcc30deec4068c' into vitest-x…
JCQuintas Nov 15, 2024
399898f
upgrade playwright
JCQuintas Nov 15, 2024
ff30d99
revert images...
JCQuintas Nov 15, 2024
9af685b
try not using static playwirhgt image
JCQuintas Nov 15, 2024
2750a58
Revert "try not using static playwirhgt image"
JCQuintas Nov 15, 2024
9d49f6d
downgrade playwright
JCQuintas Nov 15, 2024
bc93279
fix new test cases
JCQuintas Nov 15, 2024
b8d1d31
Revert "Revert "try not using static playwirhgt image""
JCQuintas Nov 15, 2024
d3a6684
run all browser
JCQuintas Nov 15, 2024
5058664
Merge commit '130063b9b3fb3131e275525b49d48a4bf930e6ed' into vitest-x…
JCQuintas Nov 18, 2024
6a85d6f
Merge commit 'bf6bd17a4d005c69ad2c3571b37c9a646e058a8d' into vitest-x…
JCQuintas Nov 19, 2024
dcb21c0
Merge branch 'master' into vitest-x-browser-working
JCQuintas Nov 19, 2024
de5877b
Revert "Revert "Revert "try not using static playwirhgt image"""
JCQuintas Nov 19, 2024
c881448
Merge branch 'master' into vitest-x-browser-working
JCQuintas Nov 19, 2024
20d745c
use latest versions
JCQuintas Nov 19, 2024
8edef9d
use noble images as focal are old
JCQuintas Nov 19, 2024
7e62e43
install ffmpeg
JCQuintas Nov 19, 2024
efd2e32
use forks instead of threads
JCQuintas Nov 19, 2024
149bf34
remove sudo
JCQuintas Nov 19, 2024
69c594c
auto accept
JCQuintas Nov 19, 2024
441b4ec
set default timeout
JCQuintas Nov 19, 2024
db141ec
revert playwright bump
JCQuintas Nov 19, 2024
3498128
force all playwright to be specific version
JCQuintas Nov 19, 2024
d1bf2d4
Merge branch 'master' into vitest-x-browser-working
JCQuintas Nov 19, 2024
9d8828a
fix local tests
JCQuintas Nov 19, 2024
f411f01
Revert "fix local tests"
JCQuintas Nov 19, 2024
ebc3172
use fake clock
JCQuintas Nov 19, 2024
c9ad767
add warning
JCQuintas Nov 19, 2024
58681e0
dedupe
JCQuintas Nov 19, 2024
4f9cc56
fix issues
JCQuintas Nov 20, 2024
e040b42
use more native behaviours
JCQuintas Nov 20, 2024
25fafe2
improve regression logic
JCQuintas Nov 20, 2024
71bf483
Merge branch 'master' into vitest-x-browser-working
JCQuintas Nov 20, 2024
825d24f
add base route
JCQuintas Nov 20, 2024
43fea96
navigate by name
JCQuintas Nov 20, 2024
bdff27a
large runner
JCQuintas Nov 20, 2024
ff2846f
try giving tests a little time
JCQuintas Nov 20, 2024
5a9c982
go back to threads
JCQuintas Nov 20, 2024
0b0a0c3
make tests slower (revert)
JCQuintas Nov 20, 2024
4797a30
revert change
JCQuintas Nov 20, 2024
d1c9d7e
revert flags
JCQuintas Nov 20, 2024
dc988a6
Merge commit '1b9df943b2270b2f6624ce7dcca02bcd83d47983' into vitest-x…
JCQuintas Nov 20, 2024
608d851
threads
JCQuintas Nov 20, 2024
d66936e
decrease thread count
JCQuintas Nov 20, 2024
4438aa1
Merge commit '6fc697840107147a8003e5e58c7ac044e24f2751' into vitest-x…
JCQuintas Nov 20, 2024
093f61e
decrease ram
JCQuintas Nov 20, 2024
8707b71
dot reporter
JCQuintas Nov 20, 2024
8302086
run browser for datagrid only
JCQuintas Nov 20, 2024
393db84
changes
JCQuintas Nov 20, 2024
1b08251
use forks
JCQuintas Nov 20, 2024
5e2e9c0
threads again...
JCQuintas Nov 20, 2024
73df0e5
increase limit
JCQuintas Nov 20, 2024
ba2e15a
allow more ram
JCQuintas Nov 20, 2024
49010a8
run only dg pro
JCQuintas Nov 20, 2024
70272b7
try a lot of params
JCQuintas Nov 21, 2024
d265568
more config
JCQuintas Nov 21, 2024
5cbc098
Merge commit '69c48b21f3e23c4e016290137721e28826799944' into vitest-x…
JCQuintas Nov 21, 2024
924da97
fix vitest test
JCQuintas Nov 21, 2024
d0f94cd
try using single fork
JCQuintas Nov 21, 2024
f7fa812
skip optimizer
JCQuintas Nov 21, 2024
c98fd74
checking
JCQuintas Nov 21, 2024
f125aab
use istanbul
JCQuintas Dec 2, 2024
b8868bb
Use coverage in browser
JCQuintas Dec 2, 2024
2364ccf
Merge commit '82d46ab329a11bf9308e8a1cf57786ac0cec37ad' into vitest-x…
JCQuintas Dec 2, 2024
6f15cae
dedupe
JCQuintas Dec 2, 2024
6408abe
fix versions
JCQuintas Dec 2, 2024
c440d24
Merge commit '65ca2086efbeb526b734db560a8e19f833562aa5' into vitest-x…
JCQuintas Dec 2, 2024
e38c84e
Merge commit 'd85fff19138b109a8d81655d55de62dbca2c6065' into vitest-x…
JCQuintas Jan 2, 2025
cdeda36
remove browser file mention
JCQuintas Jan 2, 2025
451c335
babel datefns
JCQuintas Jan 2, 2025
982e939
arrow functions
JCQuintas Jan 2, 2025
e1e0ea9
remove comments
JCQuintas Jan 2, 2025
0c04687
fix missed skip patterns
JCQuintas Jan 2, 2025
d1984a5
remove old pattern
JCQuintas Jan 2, 2025
15a057e
no return needed
JCQuintas Jan 2, 2025
ed81020
fix testskipif
JCQuintas Jan 2, 2025
e54ed0a
dedupe
JCQuintas Jan 2, 2025
b2c73f5
fix types
JCQuintas Jan 2, 2025
56c8f7e
datefns types
JCQuintas Jan 2, 2025
81a2390
fix test
JCQuintas Jan 2, 2025
5b86840
fix replace
JCQuintas Jan 2, 2025
0030cf7
use negative lookahead in datefns regexp
JCQuintas Jan 2, 2025
d796401
remove act warnings
JCQuintas Jan 2, 2025
d742e1a
fix act and remove unnecessary timers
JCQuintas Jan 2, 2025
87bf972
fix act in rows
JCQuintas Jan 2, 2025
73c5bb0
fix another act
JCQuintas Jan 2, 2025
4440524
fix act
JCQuintas Jan 2, 2025
4ab09dc
fix act
JCQuintas Jan 2, 2025
6f4194b
fix act
JCQuintas Jan 2, 2025
fbe8f10
fix act
JCQuintas Jan 2, 2025
5a1bb97
fix act
JCQuintas Jan 2, 2025
4e628db
fix act
JCQuintas Jan 2, 2025
ece6211
fix act
JCQuintas Jan 2, 2025
fbb59e5
fix act
JCQuintas Jan 2, 2025
c1caef1
act
JCQuintas Jan 3, 2025
d7db870
act
JCQuintas Jan 3, 2025
ee7522c
remove skip if
JCQuintas Jan 3, 2025
eb4fa2d
act
JCQuintas Jan 3, 2025
ed68a3d
act
JCQuintas Jan 3, 2025
cc7def7
act
JCQuintas Jan 3, 2025
e431909
act
JCQuintas Jan 3, 2025
8783db0
act
JCQuintas Jan 3, 2025
4e0a70f
act
JCQuintas Jan 3, 2025
dba0d1a
ensure time has passed
JCQuintas Jan 3, 2025
4a217e9
fixes
JCQuintas Jan 3, 2025
e1222d0
remove comment
JCQuintas Jan 3, 2025
c4590d2
Merge commit '513b8f6c404b0058636c625a4835f88c311f8468' into vitest-x…
JCQuintas Jan 3, 2025
e4e290a
IS_REACT_ACT_ENVIRONMENT and flaky tests
JCQuintas Jan 6, 2025
5140d87
fix timeout
JCQuintas Jan 6, 2025
717884e
update initial events
JCQuintas Jan 6, 2025
36397bb
use sleep for throttle
JCQuintas Jan 7, 2025
c26eba7
Merge commit '0a8dff6c944f928e8d8636b8f3df4f3731955e13' into vitest-x…
JCQuintas Jan 7, 2025
51279df
Merge commit '86d6e2a6660abc8aa8bbaa0f766aafd09ff3c8f7' into vitest-x…
JCQuintas Jan 8, 2025
2f5f809
mock fomatters
JCQuintas Jan 8, 2025
944e2b1
Merge commit '296a499c56404f7a35e0699865a694170be0842d' into vitest-x…
JCQuintas Jan 9, 2025
7c42626
Merge commit '6412b8c0a29f205a76a233ec4f07d89d179a4d8f' into vitest-x…
JCQuintas Jan 9, 2025
367629a
[AdapterDateFnsJalaliV2] Update mocks to use date-fns-jalali-v2 imports
JCQuintas Jan 14, 2025
e803e18
Merge commit 'bdd82aeac9faf01ad68ed2e8f3258c39fc29ee49' into vitest-x…
JCQuintas Jan 14, 2025
ff58b72
[test] Add long formatters mock for date-fns in AdapterDateFns tests
JCQuintas Jan 14, 2025
1b05f5a
adapters
JCQuintas Jan 14, 2025
61919e2
fix async
JCQuintas Jan 14, 2025
f6ef256
reset datefns legacy tests
JCQuintas Jan 14, 2025
d57a049
use vitest replace plugin instead of vi.mock due to typescript issues
JCQuintas Jan 14, 2025
94c1fcd
fix tests
JCQuintas Jan 14, 2025
314a9cc
fix datagrid test
JCQuintas Jan 14, 2025
f370f89
fix act warnings
JCQuintas Jan 14, 2025
3fbb79d
fix
JCQuintas Jan 14, 2025
406bf75
Merge branch 'master' into vitest-x-browser-working
JCQuintas Jan 14, 2025
f05cd7f
wait longer
JCQuintas Jan 14, 2025
f11f3df
individual configs
JCQuintas Jan 15, 2025
85df890
Merge commit '6dc3f848e886351d5c825d38381b25a3d1def904' into vitest-x…
JCQuintas Jan 15, 2025
b8fe822
run them units
JCQuintas Jan 20, 2025
8a06ca5
Merge commit '37e6a41f11d9cc43fe28864ad59465aeec21e5f0' into vitest-x…
JCQuintas Jan 20, 2025
0ec2b5a
configs
JCQuintas Jan 20, 2025
a857498
fix defaults
JCQuintas Jan 20, 2025
6c66bfe
vitest 302
JCQuintas Jan 20, 2025
1a8c3b1
Merge commit '085befa45388b4920f987b19b9a524cdfab4d786' into vitest-x…
JCQuintas Jan 20, 2025
cc788bf
dedupe
JCQuintas Jan 20, 2025
0495a41
divide pickers and datagrid
JCQuintas Jan 20, 2025
9708607
config
JCQuintas Jan 20, 2025
dd7d81f
datepickers pro changes
JCQuintas Jan 20, 2025
a3340d9
date pickers
JCQuintas Jan 20, 2025
d591723
remove old settings
JCQuintas Jan 20, 2025
a2123a0
vitest 3 config
JCQuintas Jan 20, 2025
12a33cc
config
JCQuintas Jan 21, 2025
8b70d36
Merge commit '099602fcbd1e4a0c9b7a9b9a7b266fe2e7f08fa7' into vitest-x…
JCQuintas Jan 31, 2025
ec169bb
dedupe
JCQuintas Jan 31, 2025
0f417c8
changes
JCQuintas Jan 31, 2025
b2ee3a1
Merge commit 'f5f750567470094bcd21e301aca3a8438aa6865e' into vitest-x…
JCQuintas Feb 3, 2025
dd9b531
fix issues
JCQuintas Feb 3, 2025
28343a2
setup vitest
JCQuintas Feb 3, 2025
d51f71f
fix exclusion
JCQuintas Feb 3, 2025
b89d56d
grid
JCQuintas Feb 3, 2025
944a5f4
date pickers
JCQuintas Feb 3, 2025
5ca3e01
get rid of fake clock usage
JCQuintas Feb 3, 2025
de75e5f
remove unnecessary prop
JCQuintas Feb 3, 2025
491002e
fixes
JCQuintas Feb 3, 2025
c46e176
proper config
JCQuintas Feb 3, 2025
2c226c7
changes
JCQuintas Feb 3, 2025
27e034f
Merge commit '29d6148f66780c222f5bd829e869d38a6acc9ae8' into vitest-x…
JCQuintas Feb 3, 2025
ab99b4b
fix playwright version
JCQuintas Feb 3, 2025
d796f8b
1 concurrent
JCQuintas Feb 3, 2025
9c88ffc
fix lint
JCQuintas Feb 3, 2025
e7de8e5
run charts and treeview
JCQuintas Feb 3, 2025
8b9a9c9
tsconfig
JCQuintas Feb 3, 2025
26e1354
test without coverage
JCQuintas Feb 3, 2025
5d64485
fix date utils tests
JCQuintas Feb 4, 2025
2913400
fix datagrid scroll size
JCQuintas Feb 4, 2025
3dc36ee
date pickers
JCQuintas Feb 4, 2025
1a653db
packagelock
JCQuintas Feb 4, 2025
f0da929
add timeout
JCQuintas Feb 4, 2025
371d8e4
vitest options
JCQuintas Feb 4, 2025
82b4a8a
try hover
JCQuintas Feb 4, 2025
f1762c2
Merge branch 'master' into vitest-x-browser-working
JCQuintas Feb 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/vitest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Vitest
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, this is just for ensuring the changes work while working on them

Copy link
Member

Choose a reason for hiding this comment

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

Can we remove the GH workflow given that CircleCI is already setup? 🤔


on:
push:
branches:
- 'master'
- 'next'
pull_request:
branches:
- 'master'
- 'next'

permissions: {}

jobs:
vitest-jsdom:
name: Vitest Tests (jsdom)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
with:
run_install: false
- name: Use Node.js 20.x
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: 20
cache: 'pnpm' # https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#caching-packages-dependencies
- run: pnpm install --frozen-lockfile
- name: Install Playwright Browsers
run: pnpm playwright install --with-deps
- name: Run Tests
run: pnpm vitest --project "jsdom/*"
vitest-browser:
name: Vitest Tests (browser)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
with:
run_install: false
- name: Use Node.js 20.x
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: 20
cache: 'pnpm' # https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#caching-packages-dependencies
- run: pnpm install --frozen-lockfile
- name: Install Playwright Browsers
run: pnpm playwright install --with-deps
- name: Run Tests
run: pnpm vitest --project "browser/*"
12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
"release:publish:dry-run": "pnpm publish --recursive --tag latest --registry=\"http://localhost:4873/\"",
"release:tag": "node scripts/releaseTag.mjs",
"validate": "concurrently \"pnpm prettier && pnpm eslint\" \"pnpm proptypes\" \"pnpm docs:typescript:formatted\" \"pnpm docs:api\"",
"clean:node_modules": "rimraf --glob \"**/node_modules\""
"clean:node_modules": "rimraf --glob \"**/node_modules\"",
"vitest": "cross-env TZ=UTC vitest"
},
"devDependencies": {
"@actions/core": "^1.10.1",
Expand Down Expand Up @@ -100,6 +101,7 @@
"@octokit/plugin-retry": "^7.1.1",
"@octokit/rest": "^21.0.2",
"@playwright/test": "^1.44.1",
"@testing-library/react": "^16.0.1",
"@types/babel__core": "^7.20.5",
"@types/babel__traverse": "^7.20.6",
"@types/chai": "^4.3.19",
Expand All @@ -117,6 +119,8 @@
"@types/yargs": "^17.0.33",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"@vitejs/plugin-react": "^4.3.1",
"@vitest/browser": "^2.0.5",
"autoprefixer": "^10.4.20",
"axe-core": "4.10.0",
"babel-loader": "^9.1.3",
Expand Down Expand Up @@ -191,14 +195,18 @@
"typescript": "^5.5.4",
"unist-util-visit": "^5.0.0",
"util": "^0.12.5",
"vitest": "2.0.5",
"webpack": "^5.94.0",
"webpack-bundle-analyzer": "^4.10.2",
"webpack-cli": "^5.1.4",
"yargs": "^17.7.2"
},
"resolutions": {
"react-is": "^18.3.1",
"@types/node": "^20.16.5"
"@types/node": "^20.16.5",
"@playwright/test": "1.44.1",
"playwright": "1.44.1",
JCQuintas marked this conversation as resolved.
Show resolved Hide resolved
"@mui/internal-test-utils": "https://pkg.csb.dev/mui/material-ui/commit/ae23bac4/@mui/internal-test-utils"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
33 changes: 24 additions & 9 deletions packages/x-charts/src/BarChart/checkClickEvent.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,30 @@ const isJSDOM = /jsdom/.test(window.navigator.userAgent);
describe('BarChart - click event', () => {
const { render } = createRenderer();

beforeEach(() => {
if (window?.document?.body?.style) {
window.document.body.style.margin = '0';
}
});

afterEach(() => {
if (window?.document?.body?.style) {
window.document.body.style.margin = '8px';
}
});
Comment on lines +30 to +40
Copy link
Member Author

Choose a reason for hiding this comment

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

Some charts tests are reliant screen position, and margins are different for karma and vitest, so we force one. 🙃


describe('onAxisClick', () => {
it('should provide the right context as second argument', function test() {
it('should provide the right context as second argument', function test(t = {}) {
if (isJSDOM) {
// can't do Pointer event with JSDom https://github.com/jsdom/jsdom/issues/2527
this.skip();
// @ts-expect-error to support mocha and vitest
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
this?.skip?.() || t?.skip();
Copy link
Member Author

Choose a reason for hiding this comment

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

You will see this pattern across multiple files, t = {} tells mocha to treat this as an "empty" parameter, thus not triggering the logic to provide the done() callback to it.

Without this mocha will fail because it waits for the done() to be called.

This can then be migrated to just a .skip, but vitest offers many ways of skipping test.

function test(t) {
      if (isJSDOM) {
        t.skip();
      }
}

Copy link
Member

@Janpot Janpot Oct 16, 2024

Choose a reason for hiding this comment

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

I added a shim in ./setupVitest that we cold use while the tests run in both vitest and mocha. That prevents us in core from having to update all of these right now:
https://github.com/mui/material-ui/pull/43625/files#diff-21f1d3337bd5d6e3869ad10c93fa99770a34761876017b90bc1ed1ceaa7c93a9R45-R55
Want to move this to it.skipIf eventually

The same couldn't be done for describe.skipIf that only exists in vitest, I added a shim for that in test utils:

https://github.com/mui/material-ui/pull/43625/files#diff-52e69abe336786febd0b84dbd2d9b32ba0e8f74fcf5f71669c8917d9a434c4dcR3-R9

Don't necessarily have to use it, but it can keep the amount of code changes in tests down.

}
const onAxisClick = spy();
render(
<div
style={{
margin: -8, // Removes the body default margins
width: 400,
height: 400,
}}
Expand Down Expand Up @@ -81,16 +94,17 @@ describe('BarChart - click event', () => {
});
});

it('should provide the right context as second argument with layout="horizontal"', function test() {
it('should provide the right context as second argument with layout="horizontal"', function test(t = {}) {
if (isJSDOM) {
// can't do Pointer event with JSDom https://github.com/jsdom/jsdom/issues/2527
this.skip();
// @ts-expect-error to support mocha and vitest
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
this?.skip?.() || t?.skip();
}
const onAxisClick = spy();
render(
<div
style={{
margin: -8, // Removes the body default margins
width: 400,
height: 400,
}}
Expand Down Expand Up @@ -155,16 +169,17 @@ describe('BarChart - click event', () => {
).to.deep.equal(['pointer', 'pointer', 'pointer', 'pointer']);
});

it('should provide the right context as second argument', function test() {
it('should provide the right context as second argument', function test(t = {}) {
if (isJSDOM) {
// can't do Pointer event with JSDom https://github.com/jsdom/jsdom/issues/2527
this.skip();
// @ts-expect-error to support mocha and vitest
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
this?.skip?.() || t?.skip();
}
const onItemClick = spy();
render(
<div
style={{
margin: -8, // No idea why, but that make the SVG coordinates match the HTML coordinates
width: 400,
height: 400,
}}
Expand Down
40 changes: 28 additions & 12 deletions packages/x-charts/src/ChartsTooltip/contentDisplayed.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,30 @@ const isJSDOM = /jsdom/.test(window.navigator.userAgent);
describe('ChartsTooltip', () => {
const { render } = createRenderer();

beforeEach(() => {
JCQuintas marked this conversation as resolved.
Show resolved Hide resolved
if (window?.document?.body?.style) {
JCQuintas marked this conversation as resolved.
Show resolved Hide resolved
window.document.body.style.margin = '0';
}
});

afterEach(() => {
if (window?.document?.body?.style) {
window.document.body.style.margin = '8px';
}
});

describe('axis trigger', () => {
it('should show right values with vertical layout', function test() {
it('should show right values with vertical layout', function test(t = {}) {
if (isJSDOM) {
// can't do Pointer event with JSDom https://github.com/jsdom/jsdom/issues/2527
this.skip();
// @ts-expect-error to support mocha and vitest
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
this?.skip?.() || t?.skip();
}

render(
<div
style={{
margin: -8, // Removes the body default margins
width: 400,
height: 400,
}}
Expand Down Expand Up @@ -93,16 +106,17 @@ describe('ChartsTooltip', () => {
]);
});

it('should show right values with horizontal layout', function test() {
it('should show right values with horizontal layout', function test(t = {}) {
if (isJSDOM) {
// can't do Pointer event with JSDom https://github.com/jsdom/jsdom/issues/2527
this.skip();
// @ts-expect-error to support mocha and vitest
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
this?.skip?.() || t?.skip();
}

render(
<div
style={{
margin: -8, // Removes the body default margins
width: 400,
height: 400,
}}
Expand Down Expand Up @@ -161,16 +175,17 @@ describe('ChartsTooltip', () => {
});

describe('item trigger', () => {
it('should show right values with vertical layout', function test() {
it('should show right values with vertical layout', function test(t = {}) {
if (isJSDOM) {
// can't do Pointer event with JSDom https://github.com/jsdom/jsdom/issues/2527
this.skip();
// @ts-expect-error to support mocha and vitest
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
this?.skip?.() || t?.skip();
}

render(
<div
style={{
margin: -8, // Removes the body default margins
width: 400,
height: 400,
}}
Expand Down Expand Up @@ -204,16 +219,17 @@ describe('ChartsTooltip', () => {
expect([...cells].map((cell) => cell.textContent)).to.deep.equal(['', 'S2', '1']);
});

it('should show right values with horizontal layout', function test() {
it('should show right values with horizontal layout', function test(t = {}) {
if (isJSDOM) {
// can't do Pointer event with JSDom https://github.com/jsdom/jsdom/issues/2527
this.skip();
// @ts-expect-error to support mocha and vitest
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
this?.skip?.() || t?.skip();
}

render(
<div
style={{
margin: -8, // Removes the body default margins
width: 400,
height: 400,
}}
Expand Down
40 changes: 28 additions & 12 deletions packages/x-charts/src/LineChart/checkClickEvent.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,30 @@ const isJSDOM = /jsdom/.test(window.navigator.userAgent);
describe('LineChart - click event', () => {
const { render } = createRenderer();

beforeEach(() => {
if (window?.document?.body?.style) {
window.document.body.style.margin = '0';
}
});

afterEach(() => {
if (window?.document?.body?.style) {
window.document.body.style.margin = '8px';
}
});

describe('onAxisClick', () => {
it('should provide the right context as second argument', function test() {
it('should provide the right context as second argument', function test(t = {}) {
if (isJSDOM) {
// can't do Pointer event with JSDom https://github.com/jsdom/jsdom/issues/2527
this.skip();
// @ts-expect-error to support mocha and vitest
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
this?.skip?.() || t?.skip();
}
const onAxisClick = spy();
render(
<div
style={{
margin: -8, // Removes the body default margins
width: 400,
height: 400,
}}
Expand Down Expand Up @@ -103,16 +116,17 @@ describe('LineChart - click event', () => {
]);
});

it('should provide the right context as second argument', function test() {
it('should provide the right context as second argument', function test(t = {}) {
if (isJSDOM) {
// can't do Pointer event with JSDom https://github.com/jsdom/jsdom/issues/2527
this.skip();
// @ts-expect-error to support mocha and vitest
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
this?.skip?.() || t?.skip();
}
const onMarkClick = spy();
render(
<div
style={{
margin: -8, // No idea why, but that make the SVG coordinates match the HTML coordinates
width: 400,
height: 400,
}}
Expand Down Expand Up @@ -175,16 +189,17 @@ describe('LineChart - click event', () => {
]);
});

it('should provide the right context as second argument', function test() {
it('should provide the right context as second argument', function test(t = {}) {
if (isJSDOM) {
// can't do Pointer event with JSDom https://github.com/jsdom/jsdom/issues/2527
this.skip();
// @ts-expect-error to support mocha and vitest
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
this?.skip?.() || t?.skip();
}
const onAreaClick = spy();
render(
<div
style={{
margin: -8, // No idea why, but that make the SVG coordinates match the HTML coordinates
width: 400,
height: 400,
}}
Expand Down Expand Up @@ -238,16 +253,17 @@ describe('LineChart - click event', () => {
]);
});

it('should provide the right context as second argument', function test() {
it('should provide the right context as second argument', function test(t = {}) {
if (isJSDOM) {
// can't do Pointer event with JSDom https://github.com/jsdom/jsdom/issues/2527
this.skip();
// @ts-expect-error to support mocha and vitest
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
this?.skip?.() || t?.skip();
}
const onLineClick = spy();
render(
<div
style={{
margin: -8, // No idea why, but that make the SVG coordinates match the HTML coordinates
width: 400,
height: 400,
}}
Expand Down
12 changes: 12 additions & 0 deletions packages/x-charts/src/PieChart/checkClickEvent.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ const config = {
describe('PieChart - click event', () => {
const { render } = createRenderer();

beforeEach(() => {
if (window?.document?.body?.style) {
window.document.body.style.margin = '0';
}
});

afterEach(() => {
if (window?.document?.body?.style) {
window.document.body.style.margin = '8px';
}
});

describe('onItemClick', () => {
it('should add cursor="pointer" to bar elements', function test() {
render(
Expand Down
Loading
Loading