-
Notifications
You must be signed in to change notification settings - Fork 604
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
[heft] Add support for Jest to heft. #1966
Conversation
e4e614d
to
faff2b4
Compare
|
||
"rootDir": "../../../../", | ||
"testURL": "http://localhost/", | ||
"testMatch": ["<rootDir>/lib/**/*.test.js"] |
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.
- For the
heft-test-01
project, modify the snapshot test like this:
it('Correctly handles snapshots', () => {
expect({ modified: 1, b: 2, c: 3 }).toMatchSnapshot();
});
- Run
heft test --clean
. It shows:
Tests finished:
Successes: 1
Failures: 1
Total: 2
- Now run
jest
directly. It shows:
Test Suites: 4 failed, 3 passed, 7 total
Tests: 4 failed, 10 passed, 14 total
Snapshots: 4 failed, 1 file obsolete, 3 written, 7 total
The reason is that it is matching paths like .heft/build-cache/lib/test/ExampleTest.test.js
.
To the fullest extent possible, we need the vanilla Jest CLI to behave identically as Heft's harness.
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.
we need the vanilla Jest CLI to behave identically as Heft's harness.
Let me amend this statement based on some more experimentation: The following tools all like to pretend that they are a complete toolchain:
- Webpack
- Jest
tsc --build
But they cannot realistically reproduce the entire Heft toolchain. They will fall apart when it comes to things like:
- preprocessor tasks such as json-schema-to-typescript
- postprocessor tasks such as API Extractor and
downlevel-dts
- cross-project build orchestration
--watch
mode, including Rush's upcoming cross-project watch feature
Perhaps our long-term philosophy will be like this:
- When invoked via the CLI, these tools should see config files that process their isolated inputs/outputs only
- If you run the vanilla CLIs, they should produce the same outputs that Heft would, assuming that Heft has prepared their inputs (e.g.
jest
will succeed only if Heft has created the.js
inputs) - Similarly, alternative hosts like the Jest VS Code extension only expected to work after Heft has prepared things; we should aim to polish this experience however possible
- Heft's features like
--watch
must be feature complete and expected to completely replace the vanilla CLIs - Wherever feasible, the configs should block vanilla CLI features like
jest --watch
that are not going to be meaningful
Does that make sense? The alternative would be to fully integrate Heft into each of these CLIs (i.e. replacing ts-jest
, ts-loader
, etc) which seems unrealistically expensive in general.
This also gives us an answer for the longstanding issue of const enum
not working with Webpack.
faff2b4
to
e9a22a8
Compare
This is in a generally usable state, but there are a few limitations:
|
No description provided.