Skip to content

Commit 1f039f4

Browse files
committed
feat: create jest config
1 parent 6f8a7ae commit 1f039f4

3 files changed

Lines changed: 47 additions & 1 deletion

File tree

jest.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
module.exports = {
2+
plugins: ['eslint-plugin-jest'],
3+
extends: [
4+
'plugin:eslint-plugin-jest/recommended',
5+
'plugin:eslint-plugin-jest/style'
6+
],
7+
rules: {
8+
'jest/consistent-test-it': 'error',
9+
'jest/expect-expect': [
10+
'error',
11+
// todo: TBD - this will need adjusting for react-testing-library
12+
{ assertFunctionNames: ['expect'] }
13+
],
14+
'jest/lowercase-name': [
15+
'error', // todo switch to top flag once merged
16+
{ ignore: ['describe'] }
17+
],
18+
'jest/no-expect-resolves': 'warn',
19+
'jest/no-if': 'error', // todo: rename to no-conditional-expect
20+
'jest/no-large-snapshots': 'warn',
21+
'jest/no-test-return-statement': 'error',
22+
'jest/no-truthy-falsy': 'error',
23+
'jest/prefer-called-with': 'error',
24+
// you can disable this if you use a `beforeEach` setup script,
25+
'jest/prefer-expect-assertions': 'warn',
26+
'jest/prefer-hooks-on-top': 'error',
27+
'jest/prefer-inline-snapshots': 'warn',
28+
'jest/prefer-spy-on': 'error',
29+
'jest/prefer-strict-equal': 'error',
30+
'jest/prefer-todo': 'error',
31+
'jest/require-to-throw-message': 'error',
32+
'jest/require-top-level-describe': 'error',
33+
'jest/valid-title': 'error'
34+
}
35+
};

package-lock.json

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"license": "ISC",
1111
"author": "Gareth Jones",
1212
"files": [
13-
"index.js"
13+
"index.js",
14+
"jest.js"
1415
],
1516
"scripts": {
1617
"lint": "eslint . --ignore-pattern '!.eslintrc.js' --ext js,ts",
@@ -56,6 +57,7 @@
5657
"@typescript-eslint/parser": "^2.16.0",
5758
"eslint": "^6.8.0",
5859
"eslint-plugin-eslint-comments": "^3.1.2",
60+
"eslint-plugin-jest": "^23.4.0",
5961
"eslint-plugin-local": "^1.0.0",
6062
"eslint-plugin-prettier": "^3.1.2",
6163
"husky": "^3.1.0",

0 commit comments

Comments
 (0)