Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Mar 9, 2021. It is now read-only.

Commit f442219

Browse files
timdeschryverZubair Ahmed
authored andcommitted
Add jest (#62)
* add jest * add env preset for test * run jest with --findRelatedTests
1 parent 268ee7f commit f442219

File tree

3 files changed

+45
-7
lines changed

3 files changed

+45
-7
lines changed

.babelrc

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
{
2-
"presets": ["next/babel"],
2+
"env": {
3+
"development": {
4+
"presets": "next/babel"
5+
},
6+
"production": {
7+
"presets": "next/babel"
8+
},
9+
"test": {
10+
"presets": [
11+
["env", { "modules": "commonjs" }],
12+
"next/babel"
13+
]
14+
}
15+
},
316
"plugins": [
417
[
518
"lodash",

__tests__/index.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
describe('Setting up jest', () => {
2+
it('Runs tests', () => {
3+
expect('foo').toEqual('foo');
4+
});
5+
});

package.json

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
"description": "",
55
"main": "index.js",
66
"scripts": {
7-
"test": "xo",
8-
"lint":
9-
"prettier 'utils/**/*.js' 'components/**/*.js' 'pages/**/*.js' 'lib/**/*.js' 'hocs/**/*.js' '*.js' --write --single-quote --print-width='80' --trailing-comma='all' && xo --fix",
7+
"test": "xo && jest",
8+
"lint": "prettier 'utils/**/*.js' 'components/**/*.js' 'pages/**/*.js' 'lib/**/*.js' 'hocs/**/*.js' '*.js' --write --single-quote --print-width='80' --trailing-comma='all' && xo --fix",
109
"precommit": "lint-staged",
1110
"analyze": "cross-env ANALYZE=1 next build",
1211
"dev": "cross-env NODE_ENV=development node server.js",
@@ -16,20 +15,40 @@
1615
},
1716
"xo": {
1817
"parser": "babel-eslint",
19-
"extends": ["prettier", "prettier/react", "plugin:react/recommended"],
20-
"env": ["browser", "node"],
18+
"extends": [
19+
"prettier",
20+
"prettier/react",
21+
"plugin:react/recommended"
22+
],
23+
"env": [
24+
"browser",
25+
"node"
26+
],
2127
"rules": {
2228
"linebreak-style": 0,
2329
"react/display-name": 0,
2430
"react/prop-types": 0
2531
},
2632
"space:": 2,
27-
"ignores": ["next.config.js"]
33+
"ignores": [
34+
"next.config.js"
35+
],
36+
"overrides": [
37+
{
38+
"files": "**/__tests__/*.test.js",
39+
"globals": [
40+
"describe",
41+
"it",
42+
"expect"
43+
]
44+
}
45+
]
2846
},
2947
"lint-staged": {
3048
"*.js": [
3149
"prettier --write --single-quote --print-width=80 --trailing-comma=all",
3250
"xo",
51+
"jest --findRelatedTests",
3352
"git add"
3453
]
3554
},
@@ -68,6 +87,7 @@
6887
"eslint-config-prettier": "^2.3.0",
6988
"eslint-plugin-react": "^7.1.0",
7089
"husky": "^0.14.3",
90+
"jest": "^21.2.1",
7191
"lint-staged": "^4.0.2",
7292
"normalize-url": "1.9.1",
7393
"now": "8.3.10",

0 commit comments

Comments
 (0)