| 1 | # Disallow use of deprecated functions (`no-deprecated-functions`)
|
|---|
| 2 |
|
|---|
| 3 | Over the years Jest has accrued some debt in the form of functions that have
|
|---|
| 4 | either been renamed for clarity, or replaced with more powerful APIs.
|
|---|
| 5 |
|
|---|
| 6 | While typically these deprecated functions are kept in the codebase for a number
|
|---|
| 7 | of majors, eventually they are removed completely.
|
|---|
| 8 |
|
|---|
| 9 | This rule requires knowing which version of Jest you're using - see
|
|---|
| 10 | [this section of the readme](../../README.md#jest-version-setting) for details
|
|---|
| 11 | on how that is obtained automatically and how you can explicitly provide a
|
|---|
| 12 | version if needed.
|
|---|
| 13 |
|
|---|
| 14 | ## Rule details
|
|---|
| 15 |
|
|---|
| 16 | This rule warns about calls to deprecated functions, and provides details on
|
|---|
| 17 | what to replace them with, based on the version of Jest that is installed.
|
|---|
| 18 |
|
|---|
| 19 | This rule can also autofix a number of these deprecations for you.
|
|---|
| 20 |
|
|---|
| 21 | ### `jest.resetModuleRegistry`
|
|---|
| 22 |
|
|---|
| 23 | This function was renamed to `resetModules` in Jest 15, and is scheduled for
|
|---|
| 24 | removal in Jest 27.
|
|---|
| 25 |
|
|---|
| 26 | ### `jest.addMatchers`
|
|---|
| 27 |
|
|---|
| 28 | This function was replaced with `expect.extend` in Jest 17, and is scheduled for
|
|---|
| 29 | removal in Jest 27.
|
|---|
| 30 |
|
|---|
| 31 | ### `require.requireActual` & `require.requireMock`
|
|---|
| 32 |
|
|---|
| 33 | These functions were replaced in Jest 21 and removed in Jest 26.
|
|---|
| 34 |
|
|---|
| 35 | Originally, the `requireActual` & `requireMock` the `requireActual`&
|
|---|
| 36 | `requireMock` functions were placed onto the `require` function.
|
|---|
| 37 |
|
|---|
| 38 | These functions were later moved onto the `jest` object in order to be easier
|
|---|
| 39 | for type checkers to handle, and their use via `require` deprecated. Finally,
|
|---|
| 40 | the release of Jest 26 saw them removed from the `require` function all
|
|---|
| 41 | together.
|
|---|
| 42 |
|
|---|
| 43 | ### `jest.runTimersToTime`
|
|---|
| 44 |
|
|---|
| 45 | This function was renamed to `advanceTimersByTime` in Jest 22, and is scheduled
|
|---|
| 46 | for removal in Jest 27.
|
|---|
| 47 |
|
|---|
| 48 | ### `jest.genMockFromModule`
|
|---|
| 49 |
|
|---|
| 50 | This function was renamed to `createMockFromModule` in Jest 26, and is scheduled
|
|---|
| 51 | for removal in a future version of Jest.
|
|---|