Skip to content

Commit 15c06e3

Browse files
authored
Merge branch 'main' into feat/support-jest-config-with-mts-extension
2 parents 8d4363d + 7cf3b8d commit 15c06e3

File tree

3 files changed

+148
-0
lines changed

3 files changed

+148
-0
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"`

website/versioned_docs/version-29.7/Configuration.md

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

15801580
:::
15811581

1582+
### `runtime` \[string]
1583+
1584+
Default: `"jest-runtime"`
1585+
1586+
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.
1587+
1588+
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.
1589+
1590+
:::warning
1591+
1592+
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).
1593+
1594+
:::
1595+
1596+
Example:
1597+
1598+
```js title="custom-runtime.js"
1599+
const {default: Runtime} = require('jest-runtime');
1600+
1601+
class CustomRuntime extends Runtime {
1602+
//...custom logic
1603+
}
1604+
1605+
module.exports = CustomRuntime;
1606+
```
1607+
1608+
```ts title="custom-runtime.ts"
1609+
import Runtime from 'jest-runtime';
1610+
1611+
export default class CustomRuntime extends Runtime {
1612+
//...custom logic
1613+
}
1614+
```
1615+
1616+
Add the custom runtime to your Jest configuration:
1617+
1618+
```js tab title="jest.config.js"
1619+
module.exports = {
1620+
runtime: './custom-runtime.js',
1621+
};
1622+
```
1623+
1624+
```ts tab title="jest.config.ts"
1625+
export default {
1626+
runtime: './custom-runtime.ts',
1627+
};
1628+
```
1629+
15821630
### `runner` \[string]
15831631

15841632
Default: `"jest-runner"`

website/versioned_docs/version-30.0/Configuration.md

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

15981598
:::
15991599

1600+
### `runtime` \[string]
1601+
1602+
Default: `"jest-runtime"`
1603+
1604+
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.
1605+
1606+
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.
1607+
1608+
:::warning
1609+
1610+
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).
1611+
1612+
:::
1613+
1614+
Example:
1615+
1616+
```js title="custom-runtime.js"
1617+
const {default: Runtime} = require('jest-runtime');
1618+
1619+
class CustomRuntime extends Runtime {
1620+
//...custom logic
1621+
}
1622+
1623+
module.exports = CustomRuntime;
1624+
```
1625+
1626+
```ts title="custom-runtime.ts"
1627+
import Runtime from 'jest-runtime';
1628+
1629+
export default class CustomRuntime extends Runtime {
1630+
//...custom logic
1631+
}
1632+
```
1633+
1634+
Add the custom runtime to your Jest configuration:
1635+
1636+
```js tab title="jest.config.js"
1637+
module.exports = {
1638+
runtime: './custom-runtime.js',
1639+
};
1640+
```
1641+
1642+
```ts tab title="jest.config.ts"
1643+
export default {
1644+
runtime: './custom-runtime.ts',
1645+
};
1646+
```
1647+
16001648
### `runner` \[string]
16011649

16021650
Default: `"jest-runner"`

0 commit comments

Comments
 (0)