test: Migrate to vitest
with .unpacked
and Asar Header snapshots
#351
+2,307
−1,064
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:
mocha
tovitest
verifySmartUnpack
that I pulled from electron-builder's testing approachFilesystem
operations/verifications should so be desiredunpacked
directory 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:
vitest
required droppingrimraf.sync(...)
from thebeforeEach
hooks since the tests are in parallel and would cause random tests to fail. I've moved therimraf
to thevitest-setup.ts
beforeEach
->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.ts
file change is required though foroptions?: ListOptions
to match its upstream.listFiles(options)
APIlib
required being bumped toes2019
so as to have access toflat()
APIdevDependencies
Should this PR be accepted w/
verifySmartUnpack
approach, the next steps would be cleaning up the testasserts
that are now covered by the "walking" snapshots.