Open nicojs opened 1 year ago
It might be pretty straightforward to export and document _run10000
https://github.com/facebook/jest/blob/b38d7d345a81d97d1dc3b68b8458b1837fbf19be/packages/jest-core/src/cli/index.ts#L170
I would guess that using readConfig
(or readConfigs
) instead of readInitialOptions
would work? Untested, tho
Yes, that would work. The problem is that there is currently no api (private or public) to run jest with that config.
Aha. Happy to expose that π
F.y.i. I was wondering why it was called _run10000
. But I found it here π: https://github.com/facebook/jest/pull/10000/files
@SimenB I've started some work and presented it in a draft PR: #14062
Please confirm I'm on the right track. I'll add more tests and document the whole thing in /docs
when you confirm βΊ
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
It's not stale! It has an active PR π
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
Please keep it open
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
Yeah, I'll get around to it eventually. Plz keep open
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.
Hi, I'm really interested by this feature! My use case is to run integration tests on a VSCode Extension. Basically, I want to run jest tests inside the VSCode runtime. This is well documented in VSCode, and I'm currently able to do a jest.run/jest.runCli
inside the VSCode environment. However, these functions fork into another process which loses all that context.
Would the current PR allow to run Jest without forking?
Thanks for your dedication!
π Feature Proposal
Hi πββοΈ It's me again π .
We currently use this code to resolve the jest config programmatically:
However, this doesn't seem to resolve presets. I.e. this:
Results in
{ preset: 'jest-preset-angular' }
I would love a way to resolve the entire config inc presets and use that config to run jest.
Motivation
In StrykerJS, we're running jest programmatically in the
@stryker-mutator/jest-runner
plugin. We need to wrap around the user's configured test environment because we need access to the global variables to report mutation coverage; we're using the workaround specified here: https://github.com/facebook/jest/issues/7421#issuecomment-442451426To do that, we want to know which test environment the user configured. That way, we can override that test environment by a class that extends the user's test environment (a mixin class):
When the
testEnvironment
is empty, we assume the default ("node"), which is incorrect when the preset would override to, say, "jsdom".See also: https://github.com/stryker-mutator/stryker-js/issues/4068
Example
Ideally, we would like to read the config for a project and use that in the
runCLI
API (or similar API).Pitch
A proper programmatic API would help the mission for Jest as a Platform.