-
-
Notifications
You must be signed in to change notification settings - Fork 535
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
test: migrate slow tests to use vitest #3802
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another awesome PR! 🎉
I think we could also drop the cross-env
dependency in this PR? Looks like it was only used with the Mocha test script commands. Should be able to remove it from package.json
and packages/api/core/package.json
.
@@ -11,9 +11,6 @@ | |||
"license": "MIT", | |||
"main": "dist/ViteTypeScriptTemplate.js", | |||
"typings": "dist/ViteTypeScriptTemplate.d.ts", | |||
"scripts": { | |||
"test": "mocha --config ../../../.mocharc.js test/**/*_spec_slow.ts" | |||
}, | |||
"engines": { | |||
"node": ">= 16.4.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[email protected] depends on node18+. However, the Vite template currently uses vite@5 and does not force node to be upgraded to version 18; this may be something that needs to be faced in the near future, because Vite@6 has been released for a while and it also requires node18.
At least I am leaving a message here to attract the attention of forgers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the heads-up @caoxiemeihao. We're currently looking at upgrading all Ecosystem projects to Node 22, after which we can finally bump up the supported major version range for Electron Forge!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also as a note: since vitest
is only used in CI/testing and we've already only been testing against Node 18, this doesn't block testing/release.
It's definitely a discrepancy, but since we're working on the upgrade anyways, this should be okay.
Co-authored-by: David Sanders <[email protected]>
This PR moves Electron Forge's slow test suite to use Vitest as a follow-up to #3797. A few notes:
Test migration
Migrating these tests was a lot more straightforward because they run raw commands via child process instead of asserting against mocks. These tests didn't use sinon/proxyquire at all, so I just had to change the Mocha/Chai test harness and assertion calls over to Vitest.
Fixture migration
I moved all files over to
/spec/
including test fixtures, so the actual code diff is smaller than it seems.package.json
cleanuptest
npm scripts from each individual package'spackage.json
because we run a single instance ofvitest
from the root of the package rather than usinglerna
to execute each package's individual scripts.chai
,mocha
, and associated packages are gone!Removal of unnecessary test utils
I removed
expectProjectPathExists
andexpectProjectPathNotExists
from@electron-forge/test-utils
since these helper functions were essentially callingfs.existsSync
with extra steps.Workspace organization
The
fast
andslow
suites are now assigned as Vitest workspace projects based on the test file names.vitest.config.mts
is the base file.vitest.workspace.mts
contains separate configs for slow and fast tests (mostly just increased test timeouts for the slow test suite).Note that I had to turn off file parallelism for the time being because there were issues with running multiple test files at once (potentially around FS collisions?). Once this lands, I'll open an issue to track the problem.