You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create a Jest instance asynchronously. You can provide command line arguments (for example, `process.argv`) as first argument and a list of custom [projects](./Configuration.md#projects-arraystring--projectconfig) as the second argument. If no `projects`, were configured, the current project will be provided as project config.
31
34
32
-
Example:
35
+
Examples:
33
36
34
37
```js
35
-
import {getVersion} from'jest';
36
-
console.log(`jest version: ${getVersion()}`);
37
-
```
38
+
import {createJest} from'jest';
38
39
39
-
### `readConfigs`\[function]
40
-
41
-
Async function that reads the config for a given jest project, as well as its [projects](./Configuration.md#projects-arraystring--projectconfig). If no `projects`, were configured, the current project will be provided as project config.
It takes in in an array of command line arguments (for example, `process.argv`) and an array locations to search for config.
44
+
### `jest.globalConfig`\[Readonly\<GlobalConfig>]
44
45
45
-
The configs that are returned are readonly and cannot be changed in-place. However, they can be used as a base to create new config objects from (see [Advanced use cases](#advanced-use-cases))
46
+
The global config associated with this jest instance. It is `readonly`, so it cannot be changed in-place. In order to change it, you will need to create a new object.
console.log(`Project specific configs: ${JSON.stringify(configs, null, 2)}`);
62
-
```
63
-
64
-
### `readInitialOptions`\[function]
65
-
66
-
Async function that reads the jest configuration without reading its [projects](./Configuration.md#projects-arraystring--projectconfig), resolving its [preset](./Configuration.md#preset-string), filling in the default values or validating the options.
It takes in in an array of command line arguments (for example, `process.argv`) and an array locations to search for config.
60
+
A list of project configurations associated with this jest instance. They are `readonly`, so it cannot be changed in-place. In order to change it, you will need to create a new object.
Async function that performs the run. It returns a promise that resolves in a `JestRunResult` object. This object has a `results` property that contains the actual results.
102
72
103
73
## Advanced use cases
104
74
@@ -109,54 +79,47 @@ These are more advanced use cases that demonstrate the power of the api.
109
79
You can use `readInitialOptions` in combination with `runCLI` to run jest using the local config, while forcing some options. We're also always focussing our tests on the `foo.js` file.
### Override options based on the configured options
141
107
142
108
You might want to override options based on other options. For example, you might want to provide your own version of the `jsdom` or `node` test environment.
143
109
144
-
For that to work, the initial options is not enough, because the configured preset might override the test environment.
0 commit comments