Skip to content

Commit 5515a41

Browse files
committed
docs: add runtime option to Configuration doc
1 parent 3e87145 commit 5515a41

File tree

3 files changed

+1179
-1151
lines changed

3 files changed

+1179
-1151
lines changed

docs/Configuration.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,6 +1552,58 @@ By default, `roots` has a single entry `<rootDir>` but there are cases where you
15521552

15531553
:::
15541554

1555+
### `runtime` \[string]
1556+
1557+
Default: `"jest-runtime"`
1558+
1559+
This option allows the use of a custom runtime to execute test files. A custom runtime can be provided by specifying a path to a runtime implementation.
1560+
1561+
The runtime module must export a class that extends Jest's default `Runtime` class or implements a compatible interface with the same constructor signature and methods.
1562+
1563+
:::warning
1564+
1565+
Creating a custom runtime is an advanced use case. Most users should not need to customize the runtime. Consider whether your use case might be better addressed with custom [transformers](Configuration.md#transform-objectstring-pathtotransformer--pathtotransformer-object), [test environments](Configuration.md#testenvironment-string), or [module mocks](ManualMocks.md).
1566+
1567+
:::
1568+
1569+
Example:
1570+
1571+
```js title="custom-runtime.js"
1572+
const {default: Runtime} = require('jest-runtime');
1573+
1574+
class CustomRuntime extends Runtime {
1575+
//...custom logic
1576+
}
1577+
1578+
module.exports = CustomRuntime;
1579+
```
1580+
1581+
```ts title="custom-runtime.ts"
1582+
import Runtime from 'jest-runtime';
1583+
1584+
export default class CustomRuntime extends Runtime {
1585+
//...custom logic
1586+
}
1587+
```
1588+
1589+
Add the custom runtime to your Jest configuration:
1590+
1591+
```js tab title="jest.config.js"
1592+
const {defineConfig} = require('jest');
1593+
1594+
module.exports = defineConfig({
1595+
runtime: './custom-runtime.js',
1596+
});
1597+
```
1598+
1599+
```ts tab title="jest.config.ts"
1600+
import {defineConfig} from 'jest';
1601+
1602+
export default defineConfig({
1603+
runtime: './custom-runtime.ts',
1604+
});
1605+
```
1606+
15551607
### `runner` \[string]
15561608

15571609
Default: `"jest-runner"`

0 commit comments

Comments
 (0)