Repository navigation
test: run the tests with expect-node - #869
Merged
Merged
Conversation
The tests run with expect-node, node:test with the expect and mock API of esmocha, in place of esmocha and c8: the modules of the code load as node loads them, without a transform. The imports of esmocha become the ones of expect-node (esmocha is exnode), the module mocks mock every export without an implementation, and reimport where the module under test is imported before them; the mocha compatibility keeps this.timeout, this.skip and done. The test of a failing task is skipped with yeoman-generator 4, which leaves its rejection unhandled. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
With the workers, a test file runs after others in a process that keeps the modules they imported: the module under test imported by one of them kept the modules themselves, like the actual fly-import installing a generator. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
Run the tests with expect-node, node:test with the expect and mock API esmocha gives over mocha, in place of esmocha and c8.
import()fallback,.cjs/.mjs/.tsfixtures, sibling modules): with node:test they load as node loads them, without a transform, the TypeScript run by the type stripping of node.esmochabecome the ones ofexpect-node,esmochabecomingexnode; theexpectof Jest andjest-mockare the same, and the snapshot file is read as it is.exnode.mock<typeof import('execa')>('execa')), the exports given merged over the module (fly-import), all withreimport: a worker keeps the modules the previous test files imported, so the module under test imported by one of them would keep the module itself (with 2 or 4 workers, the actualfly-importinstalled a generator, the run taking about 110 s).compatibility: 'mocha'keepsthis.timeout,this.skipand thedonetests;xitbecomesit.skip.workersrun the test files by processes reused, like mocha--parallel; the coverage ofsrcis node's. The run takes 7.9 to 9.6 s with 1 to 8 workers or a process per test file,test/resolver.tsalone taking about 6 s.generator failing task emits erroris skipped with yeoman-generator 4: it leaves the rejection of a failing task unhandled after the environment emits the error, which node:test reports and mocha ignored. The other versions cover the behavior.Comparison
Test plan
npm test(eslint, prettier, tsc, the tests with coverage)🤖 Generated with Claude Code