Skip to content

[code-infra] Replace mocha with vitest for browser & jsdom tests #14508

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 625 commits into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
625 commits
Select commit Hold shift + click to select a range
6f9e916
skip tests
JCQuintas Feb 26, 2025
d1ac98d
skip test
JCQuintas Feb 26, 2025
642e4ef
skip all in browser
JCQuintas Feb 26, 2025
ca4eaba
ignore all in browser
JCQuintas Feb 26, 2025
0f8c8cf
remove parallelism
JCQuintas Feb 26, 2025
e9853e0
fix date pickers isolation issues
JCQuintas Feb 26, 2025
11fa02b
fix datagrid isolate
JCQuintas Feb 26, 2025
a352883
fix datepickers pro isolate
JCQuintas Feb 26, 2025
1f80763
datagrid test isolate
JCQuintas Feb 26, 2025
fe0b0d6
fix charts isolate
JCQuintas Feb 26, 2025
edd2907
turn on isolate ci
JCQuintas Feb 26, 2025
abcb953
Merge commit '3697464969746f746e17342bf97cff79657dfd71' into vitest-x…
JCQuintas Feb 26, 2025
da00ea5
update packages
JCQuintas Feb 26, 2025
001e933
fix ci
JCQuintas Feb 26, 2025
dda8ecd
fix test
JCQuintas Feb 26, 2025
e17895d
add telemetry tests
JCQuintas Feb 26, 2025
f87f521
try fixes
JCQuintas Feb 26, 2025
66dc80b
try closing dialog after test
JCQuintas Feb 26, 2025
36664df
Merge branch 'master' into vitest-x-browser-working
JCQuintas Feb 26, 2025
7b7c193
remove changes
JCQuintas Feb 26, 2025
45c6a1a
fix matchmedia
JCQuintas Feb 26, 2025
533665b
m+
JCQuintas Feb 26, 2025
701bd9c
increase timeout for tests
JCQuintas Feb 26, 2025
d34359c
increase worker
JCQuintas Feb 26, 2025
aaa574f
decrease workers
JCQuintas Feb 26, 2025
9038bed
revert
JCQuintas Feb 26, 2025
f6257e4
decrease timeout
JCQuintas Feb 26, 2025
6d30ab1
add act on focus
JCQuintas Feb 27, 2025
522819b
use vmthreads
JCQuintas Feb 27, 2025
2f04cd7
env stubbing and threads
JCQuintas Feb 27, 2025
bd37ddf
fix type
JCQuintas Feb 27, 2025
3d25a4b
large
JCQuintas Feb 27, 2025
3b7044a
back to forks
JCQuintas Feb 27, 2025
106cf06
try preventing issue in charts
JCQuintas Feb 27, 2025
5c1c485
Merge commit 'ca5f2a04ebba7b4a3a31358f8e656a8d833d41c6' into vitest-x…
JCQuintas Feb 27, 2025
7ba5dbd
run on medium with single thread
JCQuintas Feb 27, 2025
12a557f
add fail on console
JCQuintas Feb 27, 2025
44b7a0a
decrease to medium
JCQuintas Feb 27, 2025
bf5ff4b
mw2
JCQuintas Feb 27, 2025
3df9fb5
big test timetout
JCQuintas Feb 27, 2025
c47e28e
disable parallelism
JCQuintas Feb 27, 2025
c0ee4a5
move to ci
JCQuintas Feb 27, 2025
445a754
comment
JCQuintas Feb 27, 2025
4ffa9f1
Merge commit '519dad717f84c43d38b66d6c8fe67f2800246e2c' into vitest-x…
JCQuintas Feb 27, 2025
74d97ef
remove global vi
JCQuintas Feb 27, 2025
c6484db
remove matrix
JCQuintas Feb 27, 2025
332a58e
speedup by removing checkout requirement
JCQuintas Feb 27, 2025
c2a78ff
upgrade vitest
JCQuintas Feb 27, 2025
d24941b
enable coverage
JCQuintas Feb 27, 2025
f7af0bb
make retry global
JCQuintas Feb 27, 2025
bd28140
remove fake clock
JCQuintas Feb 27, 2025
b62b902
remove "createFakeClock"
JCQuintas Feb 27, 2025
1de5e03
Merge commit '7eb128d9c968ea9bf3a029f8b041d41d53f168c6' into vitest-x…
JCQuintas Feb 28, 2025
42de77d
fix fake clock tests
JCQuintas Feb 28, 2025
0d66e4e
render
JCQuintas Feb 28, 2025
67a8d5a
fix wrong date
JCQuintas Feb 28, 2025
db7ede4
fix missing fake clock
JCQuintas Feb 28, 2025
a3145c1
fix waitfor
JCQuintas Feb 28, 2025
2a7508a
Merge commit 'd8d707171cda79e168c89df3474587b9322a2695' into vitest-x…
JCQuintas Mar 4, 2025
657a5ea
act and vi timers
JCQuintas Mar 4, 2025
71729a9
fix datapickers
JCQuintas Mar 4, 2025
2acfb89
Merge commit 'e895436e50fa006e1ebe7e79cf99d9f48e7d0bb2' into vitest-x…
JCQuintas Mar 4, 2025
775a4cd
Merge commit '03c32eba5313d0c71acf438941411c7641f9b72f' into vitest-x…
JCQuintas Mar 6, 2025
288eb22
fix merge issues
JCQuintas Mar 6, 2025
00da37e
Merge commit '7c80083adc800324accee8288cb6c4a58c033f55' into vitest-x…
JCQuintas Mar 6, 2025
a28374e
revert unnecessary changes
JCQuintas Mar 6, 2025
eed8451
Merge commit '53bf0013401abf2e0fe11a48a1080783a42b94b0' into vitest-x…
JCQuintas Mar 11, 2025
cc32291
dedupe
JCQuintas Mar 11, 2025
b255641
upgrade vitest
JCQuintas Mar 11, 2025
34feadf
remove unnecessary async
JCQuintas Mar 11, 2025
d1e04a2
fix grid new column menu names
JCQuintas Mar 11, 2025
fab8abb
fix issues
JCQuintas Mar 11, 2025
3f9e03b
Merge branch 'master' into vitest-x-browser-working
JCQuintas Mar 11, 2025
6d10490
Merge branch 'master' into vitest-x-browser-working
JCQuintas Mar 12, 2025
950d9f0
Merge commit '06d8025ed7b5eb14b4d125924b4eeefea9af12a2' into vitest-x…
JCQuintas Mar 12, 2025
b27c461
remove clock usage
JCQuintas Mar 12, 2025
2e1a05a
Revert "remove unnecessary async"
JCQuintas Mar 12, 2025
c5fccba
try awaiting datagrid
JCQuintas Mar 13, 2025
67c8dd7
fix react 18 unit test
JCQuintas Mar 13, 2025
f951e15
Revert "Revert "remove unnecessary async""
JCQuintas Mar 13, 2025
6603ffc
split editing keyboard
JCQuintas Mar 13, 2025
0579e1a
fix isolate browser
JCQuintas Mar 13, 2025
c564086
Merge commit '586a1c21edac8e2fb10d39548e998df658907a71' into vitest-x…
JCQuintas Mar 13, 2025
fa52763
remove overrides
JCQuintas Mar 13, 2025
f766204
revert hijri changes
JCQuintas Mar 13, 2025
be3a31f
revert hijri changes
JCQuintas Mar 13, 2025
6484f59
fix removing keys
JCQuintas Mar 14, 2025
3aa733b
Merge commit '3d7e504636461c485c798a32d9c2a7be760f9fb8' into vitest-x…
JCQuintas Mar 20, 2025
0758884
vitest upgrade
JCQuintas Mar 20, 2025
cf9d282
fixes
JCQuintas Mar 20, 2025
472e323
fix interaction
JCQuintas Mar 20, 2025
90a37c6
fix date
JCQuintas Mar 20, 2025
06c8e47
fixes
JCQuintas Mar 20, 2025
a2f15b7
fix re-render issue on use series
JCQuintas Mar 20, 2025
088dbc8
fix act warnings
JCQuintas Mar 20, 2025
9782168
Merge branch 'master' into vitest-x-browser-working
JCQuintas Mar 20, 2025
5f001e3
fix act warnings
JCQuintas Mar 20, 2025
4c71514
allow trigger none tooltip
JCQuintas Mar 20, 2025
6900304
fix grid test
JCQuintas Mar 20, 2025
f0465b5
fix heatmap tooltip issue on hooks
JCQuintas Mar 20, 2025
9cadb47
use v8 coverage
JCQuintas Mar 20, 2025
0f9a1e1
dedupe
JCQuintas Mar 20, 2025
0e5d7d4
remove istanbul
JCQuintas Mar 20, 2025
6881ecf
how fast goes fast
JCQuintas Mar 20, 2025
1014ffe
remove paralelism
JCQuintas Mar 20, 2025
bf2d395
fix workers
JCQuintas Mar 20, 2025
bf91c4d
min/max workers
JCQuintas Mar 20, 2025
66827f1
large runner
JCQuintas Mar 20, 2025
8b97b4f
large
JCQuintas Mar 20, 2025
4a94b0f
large
JCQuintas Mar 20, 2025
94f5179
medium
JCQuintas Mar 20, 2025
046d9a5
lcov only in ci
JCQuintas Mar 20, 2025
ff4839f
remove useless file
JCQuintas Mar 20, 2025
694ff3c
run coverage only on browser react-stable
JCQuintas Mar 20, 2025
cabde14
m+ browser
JCQuintas Mar 20, 2025
dbd7618
browser medium cov
JCQuintas Mar 20, 2025
655dc9c
try hanging reporters
JCQuintas Mar 20, 2025
2c2cffe
revert change
JCQuintas Mar 20, 2025
e6bf33d
Merge commit 'a95be3e3630038372947b1e0ce86f3bd076f64de' into vitest-x…
JCQuintas Mar 20, 2025
72469d5
hanging process
JCQuintas Mar 20, 2025
5798225
run again
JCQuintas Mar 21, 2025
d4f7602
Merge commit '4029bd44ddb20dd6d234ca653a3a1307ce899801' into vitest-x…
JCQuintas Mar 21, 2025
f2e674e
Merge commit '077fef10704956b8463e014816486712b95dfdea' into vitest-x…
JCQuintas Mar 21, 2025
818eb96
revert change
JCQuintas Mar 21, 2025
1c823e7
try debug
JCQuintas Mar 21, 2025
cf44d28
debug
JCQuintas Mar 21, 2025
60b754f
dot reporter
JCQuintas Mar 21, 2025
2bfe2fa
Merge commit '57e61921452fa97ee430580895da54bf4bd94e85' into vitest-x…
JCQuintas Mar 21, 2025
6651e15
config
JCQuintas Mar 21, 2025
cb69c03
Merge commit '8e9f30168042adb6dc979d74087c53e955cfed85' into vitest-x…
JCQuintas Mar 21, 2025
8b49daa
heatmap async
JCQuintas Mar 21, 2025
90d399d
Merge branch 'master' into vitest-x-browser-working
JCQuintas Mar 21, 2025
c653d01
try newer node
JCQuintas Mar 21, 2025
7ccff0e
try vmthreads
JCQuintas Mar 21, 2025
21effe6
reverts
JCQuintas Mar 21, 2025
b118a0c
Merge commit '3d47060e773edb4a5dc86e13a97aa876638fd7fb' into vitest-x…
JCQuintas Mar 21, 2025
9442953
medium+ browser
JCQuintas Mar 21, 2025
63bebdf
codecov browser
JCQuintas Mar 21, 2025
e6a59b1
fixes
JCQuintas Mar 21, 2025
09d6c38
use v8 ignore instead of istambul
JCQuintas Mar 21, 2025
e16d6af
Merge commit '02b7334fb5b2169d666ad96c2b4fc796d2cebcf0' into vitest-x…
JCQuintas Mar 21, 2025
9a85e68
comment code again
JCQuintas Mar 22, 2025
c87bf05
Merge commit '14324de82af267a39626cb02575f624011bc59d9' into vitest-x…
JCQuintas Mar 23, 2025
013aa2f
revert changes
JCQuintas Mar 23, 2025
f95e878
Merge commit '128c20ff0d5ba05b05edaec69fbf8135c0d54c71' into vitest-x…
JCQuintas Mar 24, 2025
9e9a147
use esbuild keepnames
JCQuintas Mar 24, 2025
eace5e8
Merge commit '086e9549901463ab3e5838407e381722a47e5a86' into vitest-x…
JCQuintas Mar 24, 2025
32f8f68
fix quickfilter
JCQuintas Mar 24, 2025
20dc412
add waitfor
JCQuintas Mar 24, 2025
5b5923e
fix
JCQuintas Mar 24, 2025
c761c7e
stub
JCQuintas Mar 24, 2025
1e6e65b
stub matchmedia
JCQuintas Mar 24, 2025
bc599b7
change usage
JCQuintas Mar 24, 2025
91fb565
revert react18 changes
JCQuintas Mar 24, 2025
eae931a
proper v8 ignore
JCQuintas Mar 24, 2025
1611caa
Merge branch 'master' into vitest-x-browser-working
JCQuintas Mar 24, 2025
ae3804a
fix codecov config for adapters
JCQuintas Mar 24, 2025
3011fe3
Merge branch 'master' into vitest-x-browser-working
JCQuintas Mar 25, 2025
31bb49e
Merge commit '8403fe1dc8c3f6e6f6ef0b424fb61da8a01d8c32' into vitest-x…
JCQuintas Mar 26, 2025
48f6df6
Merge commit '56a53a2126a1ea3496a748d514d2628936ca4366' into vitest-x…
JCQuintas Mar 26, 2025
b38e76a
Merge commit '4ef31c5dc9af315a0e507869ec35661860dfad3d' into vitest-x…
JCQuintas Mar 30, 2025
f2d771b
fix vitest
JCQuintas Mar 30, 2025
0edd8c6
Merge commit 'bcfea2ec18ae8bdc2f0f4cb0f7c58197f49007a6' into vitest-x…
JCQuintas Mar 31, 2025
4c134dd
Merge branch 'master' into vitest-x-browser-working
JCQuintas Mar 31, 2025
1dee4a5
Merge commit '9e4fc87b92ec2a0ce276c95a00e670e9f828cca2' into vitest-x…
JCQuintas Apr 1, 2025
83fee2c
revert
JCQuintas Apr 1, 2025
0486002
remove
JCQuintas Apr 1, 2025
f8875b5
await
JCQuintas Apr 1, 2025
4de744b
fix timeout
JCQuintas Apr 2, 2025
a6c43c2
fix chart test
JCQuintas Apr 2, 2025
a2f0118
remove unnecessary fake time
JCQuintas Apr 2, 2025
8a71d26
wait for
JCQuintas Apr 2, 2025
60abcae
fix imports
JCQuintas Apr 2, 2025
8eefc86
Merge commit '6a85377776e7703e43e709edd12ce17e48205387' into vitest-x…
JCQuintas Apr 4, 2025
30c0a78
merge charts changes
JCQuintas Apr 4, 2025
df32df6
fix zoom tests
JCQuintas Apr 4, 2025
d00f23f
system time
JCQuintas Apr 4, 2025
aa48514
styling
JCQuintas Apr 4, 2025
5b84db7
Merge commit 'b850e86595e9cfce4312f88213b567707ca5ae5d' into vitest-x…
JCQuintas Apr 4, 2025
7688c24
improve ishydrated
JCQuintas Apr 4, 2025
2099068
fix data
JCQuintas Apr 4, 2025
ba95ff2
merge
JCQuintas Apr 4, 2025
ad3f611
Merge commit 'cac327103f8ebe7434955a94d6cdfdd8f5974a47' into vitest-x…
JCQuintas Apr 21, 2025
8a035c9
changes
JCQuintas Apr 22, 2025
43e690f
fix new changes and versions
JCQuintas Apr 22, 2025
2d7f73a
fixes
JCQuintas Apr 22, 2025
92e7a5d
Merge commit 'dbfc3fea456bd5d73ea8712d9f43368857cdc102' into vitest-x…
JCQuintas Apr 26, 2025
f488dc0
dedupe
JCQuintas Apr 26, 2025
5e9bc5f
Revert changes and add global cleanup
JCQuintas Apr 26, 2025
4884ea0
revert
JCQuintas Apr 26, 2025
14d13d6
react 18 errors
JCQuintas Apr 26, 2025
8cc7625
remove waitfor
JCQuintas Apr 26, 2025
b980147
reset
JCQuintas Apr 27, 2025
72b65f7
remove unused file
JCQuintas Apr 27, 2025
bff64d3
Add minimum for hijri tests to work in vitest browser
JCQuintas Apr 27, 2025
58e2122
try wait for
JCQuintas Apr 27, 2025
8d279c2
Merge commit 'cb6ae5571c5de70cfea80580553702acdc92be26' into vitest-x…
JCQuintas Apr 27, 2025
f429669
Fix datagrid changes
JCQuintas Apr 27, 2025
fea979f
scripts
JCQuintas Apr 27, 2025
87c54ae
remove config
JCQuintas Apr 27, 2025
3082de9
clear cache after run
JCQuintas Apr 28, 2025
835754e
fix changes
JCQuintas Apr 28, 2025
06c71de
update scripts
JCQuintas Apr 28, 2025
702b3f9
revert clearwarning changes
JCQuintas Apr 29, 2025
89c7309
Try defined size
JCQuintas Apr 29, 2025
1e72fe9
Merge commit 'f8f131e9a4fe4bbee0347cbb82156ff2629f2938' into vitest-x…
JCQuintas Apr 29, 2025
f9c5136
increase parent size
JCQuintas Apr 29, 2025
f01ec53
change script names
JCQuintas Apr 29, 2025
f1eb72c
change test behavior
JCQuintas Apr 29, 2025
300280b
add todo
JCQuintas Apr 29, 2025
a2c8da2
Merge commit '08e50e5b5863391c9375c8b22816ddb3c9a971a4' into vitest-x…
JCQuintas Apr 29, 2025
1b9aa40
Merge commit 'ae8e2fb361dfa97615fe56c6ff2feeed3864896c' into vitest-x…
JCQuintas Apr 30, 2025
7af50b2
improve dx
JCQuintas Apr 30, 2025
350a520
Revert "random"
JCQuintas Apr 30, 2025
a3fa338
lockfile
JCQuintas Apr 30, 2025
59a34ff
Merge commit '7d52f102ec9a691746d0959ebab7e8815473a8a6' into vitest-x…
JCQuintas Apr 30, 2025
eea2b4f
Revert "timer reversals"
JCQuintas Apr 30, 2025
e45be58
fix date
JCQuintas Apr 30, 2025
58bc33b
Revert "possible changes"
JCQuintas Apr 30, 2025
905fdc8
fix
JCQuintas Apr 30, 2025
4ddaa3e
fix
JCQuintas Apr 30, 2025
b9221d2
change date
JCQuintas Apr 30, 2025
5578a65
use vite timers
JCQuintas Apr 30, 2025
f0ae783
Merge commit '870970914f72539a93231181d0ab6b89903f9e4e' into vitest-x…
JCQuintas Apr 30, 2025
6844bd0
Merge commit '8f0728b2269a96939a4a6b5045e4bf5bd8c18be8' into vitest-x…
JCQuintas May 1, 2025
3da419f
Revert to use vi timers
JCQuintas May 1, 2025
6695614
improvements
JCQuintas May 1, 2025
48ba1db
mergein
JCQuintas May 1, 2025
8b11847
suggestions
JCQuintas May 1, 2025
b03ee5b
change msg
JCQuintas May 1, 2025
23ab3c2
dedupe
JCQuintas May 1, 2025
b8b510b
add back
JCQuintas May 1, 2025
62561b6
suggestions
JCQuintas May 1, 2025
46c7c34
address scripts comments
JCQuintas May 5, 2025
ce34df4
Merge commit 'c25066404f6e0ed4a02ebc63d483597894a29c46' into vitest-x…
JCQuintas May 6, 2025
8b35b39
suggestions
JCQuintas May 6, 2025
65fe98d
re-enable pickers test that was failing
JCQuintas May 6, 2025
f158e0e
reverts
JCQuintas May 6, 2025
2877d64
Merge commit '53fd0e32860985c6629346ffd844dd674a78ddb1' into vitest-x…
JCQuintas May 7, 2025
ef3a9bd
vitest redirect imports
JCQuintas May 7, 2025
fb13349
exclude -> include
JCQuintas May 7, 2025
b87e324
Update test/vite-plugin-filter-replace.mts
JCQuintas May 7, 2025
46a2b70
move includes to prop of config
JCQuintas May 7, 2025
b6d49c6
change to single include and document
JCQuintas May 7, 2025
cd8161d
add /locale back
JCQuintas May 7, 2025
fce7e7a
formatting
JCQuintas May 7, 2025
dc5e792
Merge commit 'c3fe709fe61282c152fbbdc0bc812080ec6e9fc3' into vitest-x…
JCQuintas May 7, 2025
b981102
prettier
JCQuintas May 8, 2025
480de46
simple projects names
JCQuintas May 8, 2025
73c6a59
Merge branch 'master' into vitest-x-browser-working
JCQuintas May 8, 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
93 changes: 52 additions & 41 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,19 @@ parameters:
type: string
default: ''

default-parameters: &default-parameters
react-version:
description: The version of react to be used
type: string
default: << pipeline.parameters.react-version >>
e2e-base-url:
description: The base url for running end-to-end test
type: string
default: << pipeline.parameters.e2e-base-url >>

default-job: &default-job
parameters:
react-version:
description: The version of react to be used
type: string
default: << pipeline.parameters.react-version >>
e2e-base-url:
description: The base url for running end-to-end test
type: string
default: << pipeline.parameters.e2e-base-url >>
<<: *default-parameters
environment:
# expose it globally otherwise we have to thread it from each job to the install command
BROWSERSTACK_FORCE: << pipeline.parameters.browserstack-force >>
Expand Down Expand Up @@ -150,21 +153,46 @@ jobs:
- install_js:
react-version: << parameters.react-version >>
- run:
name: Tests fake browser
command: pnpm test:coverage
- run:
name: Check coverage generated
command: |
if ! [[ -s coverage/lcov.info ]]
then
exit 1
fi
- run:
name: Coverage
command: |
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
./codecov -t ${CODECOV_TOKEN} -Z -F "$REACT_VERSION-jsdom"
name: Test JSDOM
command: pnpm test:unit:jsdom

test_browser:
<<: *default-job
resource_class: medium+
steps:
- checkout
- install_js:
playwright: true
react-version: << parameters.react-version >>
- when:
condition:
not:
equal: ['stable', << parameters.react-version >>]
steps:
- run:
name: Test Browser
command: pnpm test:unit:browser
- when:
condition:
equal: ['stable', << parameters.react-version >>]
steps:
- run:
name: Test Browser + Coverage
command: pnpm test:unit:browser --coverage
- run:
name: Check coverage generated
command: |
if ! [[ -s coverage/lcov.info ]]
then
exit 1
fi
- run:
name: Coverage
command: |
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
./codecov -t ${CODECOV_TOKEN} -Z -F "$REACT_VERSION-browser"

test_lint:
<<: *default-job
steps:
Expand Down Expand Up @@ -242,21 +270,6 @@ jobs:
else
exit 0
fi

test_browser:
<<: *default-job
steps:
- checkout
- install_js:
playwright: true
react-version: << parameters.react-version >>
- run:
name: Tests real browsers
command: pnpm test:karma
- store_artifacts:
# hardcoded in karma-webpack
path: /tmp/_karma_webpack_
destination: artifact-file
test_types:
<<: *default-job
steps:
Expand Down Expand Up @@ -353,9 +366,7 @@ workflows:
jobs:
- checkout:
<<: *default-context
- test_e2e_website:
requires:
- checkout
- test_e2e_website

additional-tests:
when:
Expand Down
24 changes: 0 additions & 24 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,30 +105,6 @@ module.exports = function getBabelConfig(api) {
],
];

if (process.env.NODE_ENV === 'test') {
plugins.push(['@babel/plugin-transform-export-namespace-from']);
// We replace `date-fns` imports with an aliased `date-fns@v2` version installed as `date-fns-v2` for tests.
plugins.push([
'babel-plugin-replace-imports',
{
test: /date-fns/i,
replacer: 'date-fns-v2',
// This option is provided by the `patches/[email protected]` patch
filenameIncludes: 'src/AdapterDateFnsV2/',
},
]);
plugins.push([
'babel-plugin-replace-imports',
{
test: /date-fns-jalali/i,
replacer: 'date-fns-jalali-v2',
// This option is provided by the `patches/[email protected]` patch
filenameIncludes: 'src/AdapterDateFnsJalaliV2/',
},
'replace-date-fns-jalali-imports',
]);
}

if (process.env.NODE_ENV === 'production') {
if (!process.env.TEST_BUILD) {
plugins.push(['babel-plugin-react-remove-properties', { properties: ['data-testid'] }]);
Expand Down
3 changes: 2 additions & 1 deletion docs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"resolveJsonModule": true,
"skipLibCheck": true,
"esModuleInterop": true,
"incremental": true
"incremental": true,
"types": ["@mui/internal-test-utils/initMatchers", "chai-dom", "mocha"]
},
"include": ["next-env.d.ts", "next.config.mjs", "docs-env.d.ts", "src", "pages/**/*.ts*", "data"],
"exclude": ["docs/.next", "docs/export", "pages/playground"]
Expand Down
13 changes: 13 additions & 0 deletions docs/vitest.config.jsdom.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { mergeConfig, defineProject } from 'vitest/config';
import sharedConfig from '../vitest.shared.mts';
import { getTestName } from '../scripts/getTestName.mts';

export default mergeConfig(
sharedConfig,
defineProject({
test: {
name: getTestName(import.meta.url),
environment: 'jsdom',
},
}),
);
14 changes: 9 additions & 5 deletions mui-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
export {}; // Ensure this file is treated as a module to avoid global scope TS error

declare global {
interface MUIEnv {
NODE_ENV?: string;
}

interface Process {
env: MUIEnv;
}

// support process.env.NODE_ENV === '...'
// @ts-ignore
const process: {
env: {
NODE_ENV?: string;
};
};
const process: Process;
}
26 changes: 14 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@
"proptypes": "tsx ./docs/scripts/generateProptypes.ts",
"size:snapshot": "node --max-old-space-size=2048 ./scripts/sizeSnapshot/create",
"size:why": "pnpm size:snapshot --analyze --accurateBundles",
"tc": "node test/cli.js",
"test": "node scripts/test.mjs",
Comment on lines -35 to -36
Copy link
Member

Choose a reason for hiding this comment

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

Both of these scripts were mainly maintained and used by @oliviertassinari.
After these changes, they seem to be partially no longer needed, hence, they could be removed.

However, am I missing something @JCQuintas, or is Vitest simply much slower at grep filtering tests? 🤔
Below are the results of running pnpm test --testNamePattern=DateRangePicker vs pnpm test:unit --grep DateRangePicker:
Screenshot 2025-05-05 at 08 24 09
Screenshot 2025-05-05 at 08 34 11
Given these differences, pattern matching test no longer seems like a viable option. 🙈

Side nitpick: Would it make sense to keep the existing test:unit script to ensure that muscle memory usage still works for everybody? 🙈 😆

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess the --testNamePattern= makes it slow somehow 😆

if you just run pnpm test DateRangePicker
Screenshot 2025-05-05 at 09 19 23

Copy link
Member Author

Choose a reason for hiding this comment

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

removed the scripts

Copy link
Member

Choose a reason for hiding this comment

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

I guess the --testNamePattern= makes it slow somehow 😆

if you just run pnpm test DateRangePicker

That's strange... 🙈
I reckon this will need some getting used to and unlearning old habits. 🤔 🙈

Copy link
Member

@oliviertassinari oliviertassinari May 5, 2025

Choose a reason for hiding this comment

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

  1. How much time does it take to run the tests in watch mode for a specific test file?
  2. What's the time difference with pnpm tc?
  3. What are people using today if not pnpm tc? I mean, I don't understand what's the viable alternative to it. In Material UI, the process used to be running all the tests in watch mode, that worked when it was taking 30s to run all the tests, but overtime, we kept making the CI slower, with slower assertions, slower selectors, slower setup, etc. so we moved to running tests per file.

Copy link
Member

Choose a reason for hiding this comment

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

3. What are people using today if not pnpm tc? I mean, I don't understand what's the viable alternative to it. In Material UI, the process used to be running all the tests in watch mode, that worked when it was taking 30s to run all the tests, but overtime, we kept making the CI slower, with slower assertions, slower selectors, slower setup, etc. so we moved to running tests per file.

I currently use describe.only or it.only or test:unit --grep <pattern>.
Didn't see the need for anything else for now... 🤷

Copy link
Member

@oliviertassinari oliviertassinari May 6, 2025

Choose a reason for hiding this comment

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

The need was to support the work on around 10 PRs a day, most as reviews of others work. I would most often verify that the test was failing without the fix, and add missing tests. I couldn't stand to checkout a branch and wait a long time for the tests the PR changes to run. Usually when changing branches watch mode would break, you had to restart it. pnpm tc purpose was to allow to run the tests in < 10s.

Copy link
Member Author

Choose a reason for hiding this comment

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

As far as I understand pnpm tc and pnpm vitest are comparable. In the examples below I'm running tc in --single mode to prevent watch, and test:jsdom with CI=true to also prevent watch.

Keep in mind if I use tc without the --single it is erroring with "too many watchers", while vitest works out of the box.

time pnpm test --single BarChart.test.tsx

> @8.2.0 test /Users/jcquintas/dev/mui/mui-x
> node scripts/test.mjs --single BarChart.test.tsx

Running selected tests in watch mode...
Note: run `pnpm tc` to have a better experience (and be able to pass in additional parameters).
cmd [ 'tc', '--single', 'BarChart.test.tsx' ]

> @8.2.0 tc /Users/jcquintas/dev/mui/mui-x
> node test/cli.js --single BarChart.test.tsx

1
including inaccessible elements by default


  ..,,....

  6 passing (101ms)
  2 pending

pnpm test --single BarChart.test.tsx  3.02s user 0.68s system 109% cpu 3.362 total
time CI=true pnpm test:jsdom BarChart.test.tsx

> @8.1.0 test:jsdom /Users/jcquintas/dev/mui/mui-x-vitest
> pnpm test:unit:jsdom BarChart.test.tsx


> @8.1.0 test:unit:jsdom /Users/jcquintas/dev/mui/mui-x-vitest
> cross-env NODE_ENV=test TZ=UTC JSDOM=true vitest BarChart.test.tsx


 RUN  v3.1.2 /Users/jcquintas/dev/mui/mui-x-vitest

 ✓  x-charts  src/BarChart/BarChart.test.tsx (8 tests | 2 skipped) 116ms

 Test Files  1 passed (1)
      Tests  6 passed | 2 skipped (8)
   Start at  17:56:40
   Duration  3.59s (transform 1.72s, setup 2.69s, collect 249ms, tests 116ms, environment 218ms, prepare 76ms)

CI=true pnpm test:jsdom BarChart.test.tsx  6.40s user 1.82s system 179% cpu 4.590 total

Copy link
Member

@oliviertassinari oliviertassinari May 6, 2025

Choose a reason for hiding this comment

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

Alright, so does it mean that we can update https://github.com/mui/material-ui/blob/HEAD/test/README.md#getting-started with something equivalent?

Copy link
Member Author

Choose a reason for hiding this comment

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

Eventually, yes, that is the goal. But this PR is for the X repo, not material

"test:coverage": "cross-env NODE_OPTIONS=--max-old-space-size=4096 NODE_ENV=test TZ=UTC BABEL_ENV=coverage nyc mocha 'packages/**/*.test.{js,ts,tsx}' 'docs/**/*.test.{js,ts,tsx}' && nyc report -r lcovonly",
"test:coverage:html": "cross-env NODE_ENV=test TZ=UTC BABEL_ENV=coverage nyc mocha 'packages/**/*.test.{js,ts,tsx}' 'docs/**/*.test.{js,ts,tsx}' && nyc report --reporter=html",
"test:coverage:inspect": "cross-env NODE_ENV=test TZ=UTC BABEL_ENV=coverage mocha --inspect-brk",
"test:karma": "cross-env NODE_ENV=test TZ=UTC karma start test/karma.conf.js",
"test:karma:parallel": "cross-env NODE_ENV=test TZ=UTC PARALLEL=true karma start test/karma.conf.js",
"test:unit": "cross-env NODE_ENV=test TZ=UTC mocha -n expose_gc 'packages/**/*.test.{js,ts,tsx}' 'docs/**/*.test.{js,ts,tsx}'",
"test": "pnpm test:unit:jsdom",
"test:jsdom": "pnpm test:unit:jsdom",
"test:unit": "pnpm test:unit:jsdom",
"test:unit:jsdom": "cross-env NODE_ENV=test TZ=UTC JSDOM=true vitest",
"test:browser": "pnpm test:unit:browser",
"test:unit:browser": "cross-env NODE_ENV=test TZ=UTC BROWSER=true vitest",
"test:e2e": "pnpm run release:build && cd test/e2e && pnpm run start",
"test:e2e-website": "npx playwright test test/e2e-website --config test/e2e-website/playwright.config.ts",
"test:e2e-website:dev": "PLAYWRIGHT_TEST_BASE_URL=http://localhost:3001 npx playwright test test/e2e-website --config test/e2e-website/playwright.config.ts",
Expand Down Expand Up @@ -99,7 +97,6 @@
"@playwright/test": "^1.52.0",
"@types/babel__core": "^7.20.5",
"@types/babel__traverse": "^7.20.7",
"@types/chai": "^4.3.20",
"@types/chai-dom": "^1.11.3",
"@types/fs-extra": "^11.0.4",
"@types/karma": "^6.3.9",
Expand All @@ -113,6 +110,9 @@
"@types/yargs": "^17.0.33",
"@typescript-eslint/eslint-plugin": "^8.31.1",
"@typescript-eslint/parser": "^8.31.1",
"@vitejs/plugin-react": "^4.3.2",
"@vitest/browser": "^3.1.2",
"@vitest/coverage-v8": "^3.1.2",
"@vvago/vale": "^3.11.2",
"autoprefixer": "^10.4.21",
"axe-core": "4.10.3",
Expand All @@ -121,7 +121,6 @@
"babel-plugin-module-resolver": "^5.0.2",
"babel-plugin-optimize-clsx": "^2.6.2",
"babel-plugin-react-remove-properties": "^0.3.0",
"babel-plugin-replace-imports": "^1.0.2",
"babel-plugin-search-and-replace": "^1.1.1",
"babel-plugin-transform-inline-environment-variables": "^0.4.4",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
Expand All @@ -135,6 +134,7 @@
"danger": "^13.0.4",
"date-fns-jalali-v2": "npm:[email protected]",
"date-fns-v2": "npm:[email protected]",
"esbuild": "^0.25.3",
"eslint": "^8.57.1",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-base": "^15.0.0",
Expand Down Expand Up @@ -169,6 +169,7 @@
"karma-webpack": "^5.0.1",
"lerna": "^8.2.2",
"lodash": "^4.17.21",
"magic-string": "^0.30.17",
"markdownlint-cli2": "^0.17.2",
"mocha": "^11.2.2",
"moment": "^2.30.1",
Expand All @@ -192,6 +193,8 @@
"unist-util-visit": "^5.0.0",
"util": "^0.12.5",
"vite": "^6.3.4",
"vitest": "3.1.2",
"vitest-fail-on-console": "^0.7.1",
"webpack": "^5.99.7",
"webpack-bundle-analyzer": "^4.10.2",
"webpack-cli": "^6.0.1",
Expand All @@ -204,8 +207,7 @@
},
"pnpm": {
"patchedDependencies": {
"[email protected]": "patches/[email protected]",
"[email protected]": "patches/[email protected]"
"[email protected]": "patches/[email protected]"
},
"onlyBuiltDependencies": [
"@swc/core",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ describeSkipIf(isJSDOM)('<BarChartPro /> - Zoom', () => {
}
});

it('should zoom on wheel', async function test() {
this.timeout(10000);
it('should zoom on wheel', async () => {
const onZoomChange = sinon.spy();
const { user } = render(
<BarChartPro {...barChartProps} onZoomChange={onZoomChange} />,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ describeSkipIf(isJSDOM)('<LineChartPro /> - Zoom', () => {
}
});

it('should zoom on wheel', async function test() {
this.timeout(10000);
it('should zoom on wheel', async () => {
const onZoomChange = sinon.spy();
const { user } = render(
<LineChartPro {...lineChartProps} onZoomChange={onZoomChange} />,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ describeSkipIf(isJSDOM)('<ScatterChartPro /> - Zoom', () => {
}
});

it('should zoom on wheel', async function test() {
this.timeout(10000);
it('should zoom on wheel', async () => {
const onZoomChange = sinon.spy();
const { user } = render(
<ScatterChartPro {...scatterChartProps} onZoomChange={onZoomChange} />,
Expand Down
19 changes: 19 additions & 0 deletions packages/x-charts-pro/vitest.config.browser.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/// <reference types="@vitest/browser/providers/playwright" />
import { mergeConfig } from 'vitest/config';
import sharedConfig from '../../vitest.shared.mts';
import { getTestName } from '../../scripts/getTestName.mts';

export default mergeConfig(sharedConfig, {
test: {
name: getTestName(import.meta.url),
environment: 'browser',
browser: {
enabled: true,
instances: [
{
browser: 'chromium',
},
],
},
},
});
10 changes: 10 additions & 0 deletions packages/x-charts-pro/vitest.config.jsdom.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { mergeConfig } from 'vitest/config';
import sharedConfig from '../../vitest.shared.mts';
import { getTestName } from '../../scripts/getTestName.mts';

export default mergeConfig(sharedConfig, {
test: {
name: getTestName(import.meta.url),
environment: 'jsdom',
},
});
19 changes: 19 additions & 0 deletions packages/x-charts-vendor/vitest.config.browser.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/// <reference types="@vitest/browser/providers/playwright" />
import { mergeConfig } from 'vitest/config';
import sharedConfig from '../../vitest.shared.mts';
import { getTestName } from '../../scripts/getTestName.mts';

export default mergeConfig(sharedConfig, {
test: {
name: getTestName(import.meta.url),
environment: 'browser',
browser: {
enabled: true,
instances: [
{
browser: 'chromium',
},
],
},
},
});
10 changes: 10 additions & 0 deletions packages/x-charts-vendor/vitest.config.jsdom.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { mergeConfig } from 'vitest/config';
import sharedConfig from '../../vitest.shared.mts';
import { getTestName } from '../../scripts/getTestName.mts';

export default mergeConfig(sharedConfig, {
test: {
name: getTestName(import.meta.url),
environment: 'jsdom',
},
});
19 changes: 19 additions & 0 deletions packages/x-charts/vitest.config.browser.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/// <reference types="@vitest/browser/providers/playwright" />
import { mergeConfig } from 'vitest/config';
import sharedConfig from '../../vitest.shared.mts';
import { getTestName } from '../../scripts/getTestName.mts';

export default mergeConfig(sharedConfig, {
test: {
name: getTestName(import.meta.url),
environment: 'browser',
browser: {
enabled: true,
instances: [
{
browser: 'chromium',
},
],
},
},
});
Loading