-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest.js
54 lines (50 loc) · 1.58 KB
/
jest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
module.exports = {
// Let ESLint know we are using the common Jest environment and its globals
"env": {
"jest": true,
"jest/globals": true,
},
// Include jest and node plugin
"plugins": [
"node",
"jest",
],
// Extend sharable configs from jest
"extends": [
"plugin:jest/recommended",
// Reason: Style of tests, assertions and better error messages
"plugin:jest/style",
],
"rules": {
// Reason: Some matcher aliases are easier to understand (grammar)
"jest/no-alias-methods": "off",
// Reason: Ensures the correct error was thrown and not a logic or testing error
"jest/require-to-throw-message": "error",
// Reason: Possible error or confusing format of test hooks
"jest/no-duplicate-hooks": "error",
// Reason: Avoid loosing hooks in the middle of tests when they will apply to ones above and below
"jest/prefer-hooks-on-top": "error",
// Reason: Avoid writing extremely loose tests like `expect(value).toBeTruthy()`
"jest/no-restricted-matchers": [
"error",
{
"toBeFalsy": "Use a more restrictive expectation e.g. `.toBe(false)`, `.toBeNull()`, `.not.toBeInTheDocument()`",
"toBeTruthy": "Use a more restrictive expectation e.g. `.toBe(true)`, `.toEqual(value)`, `.toBeInTheDocument()`",
},
],
},
"overrides": [
{
// Apply to TypeScript files
"files": [
"**/*.{ts,tsx}",
],
"rules": {
// Reason: Replace unbound method lint rules in TypeScript to automatically allow certain
// unbound methods that are safe in tests
"@typescript-eslint/unbound-method": "off",
"jest/unbound-method": "error",
},
},
],
};