test: Migrate to vitest with .unpacked and Asar Header snapshots#351
Draft
mmaietta wants to merge 5 commits intoelectron:mainfrom
Draft
test: Migrate to vitest with .unpacked and Asar Header snapshots#351mmaietta wants to merge 5 commits intoelectron:mainfrom
vitest with .unpacked and Asar Header snapshots#351mmaietta wants to merge 5 commits intoelectron:mainfrom
Conversation
Contributor
Author
|
Whelp, looks like this PR would depend on the upcoming node 22 upgrade. CC @erickzhao |
vitest with .unpacked and Asar Header snapshotsvitest with .unpacked and Asar Header snapshots
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Was having a fun chat with @erickzhao and wanted to see if I could lend a hand!
This PR accomplishes a few things:
mochatovitestverifySmartUnpackthat I pulled from electron-builder's testing approachFilesystemoperations/verifications should so be desiredunpackeddirectory and stores a snapshot of the folder/file/symlink hierarchy.With
verifySmartUnpack, the header snapshot allows finer granularity of what is happening under the hood, especially with regards to symlinks and integrity calculations. Example respective snapshots excerpts below:Then the "walk" snapshot functionality allows all these lines to become just
verifySmartUnpack('tmp/packthis-unpack-subdir-cli.asar')asar/test/cli-spec.js
Lines 182 to 185 in 121efeb
Additional Notes:
vitestrequired droppingrimraf.sync(...)from thebeforeEachhooks since the tests are in parallel and would cause random tests to fail. I've moved therimrafto thevitest-setup.tsbeforeEach->rimraf, the tests need to run in isolation (which I wasn't able to achieve withsingleThread) OR a random tmp dir is used each time that is unique to each test case. The latter option would require too large of a change and I wanted to keep changes in this PR isolated to thetest/folder as much as possible.src/asar.tsfile change is required though foroptions?: ListOptionsto match its upstream.listFiles(options)APIlibrequired being bumped toes2019so as to have access toflat()APIdevDependenciesShould this PR be accepted w/
verifySmartUnpackapproach, the next steps would be cleaning up the testassertsthat are now covered by the "walking" snapshots.