@@ -11,10 +11,10 @@ Require Jest module mocking APIs to be called before any other statements in the
11
11
12
12
#### Rule Details
13
13
14
- Jest module mocking APIs such as "jest.mock(\' ./example \' )" must be called before the associated module
15
- is imported, otherwise they will have no effect. Transpilers such as ts-jest and babel-jest automatically
16
- "hoist" these calls, however this can produce counterintuitive results . Instead, the hoist-jest-mocks
17
- lint rule requires developers to manually hoist these calls .
14
+ Jest module mocking APIs such as "jest.mock()" must be called before the associated module is imported, otherwise
15
+ they will have no effect. Transpilers such as ` ts-jest ` and ` babel-jest ` automatically "hoist" these calls, however
16
+ this can produce counterintuitive behavior . Instead, the ` hoist-jest-mocks ` lint rule simply requires developers
17
+ to write the statements in the correct order .
18
18
19
19
The following APIs are affected: 'jest.mock()', 'jest.unmock()', 'jest.enableAutomock()', 'jest.disableAutomock()',
20
20
'jest.deepUnmock()'.
@@ -38,11 +38,11 @@ test("example", () => {
38
38
The following patterns are NOT considered problems:
39
39
40
40
``` ts
41
- jest .mock (' ./file' );
41
+ jest .mock (' ./file' ); // okay, because mock() is first
42
42
import * as file from ' ./file' ;
43
43
44
44
test (" example" , () => {
45
- jest .mock (' ./file2' );
45
+ jest .mock (' ./file2' ); // okay, because mock() is first within the test() code block
46
46
const file2: typeof import (' ./file2' ) = require (' ./file2' );
47
47
});
48
48
```
@@ -216,4 +216,3 @@ enum E {
216
216
}
217
217
let e: E ._PrivateMember = E ._PrivateMember ; // okay, because _PrivateMember is declared by E
218
218
```
219
-
0 commit comments