Skip to content
This repository was archived by the owner on Mar 9, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions __tests__/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe('Setting up jest', () => {
it('Runs tests', () => {
expect('foo').toEqual('foo');
});
});
34 changes: 26 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
"description": "",
"main": "index.js",
"scripts": {
"test": "xo",
"lint":
"prettier 'utils/**/*.js' 'components/**/*.js' 'pages/**/*.js' 'lib/**/*.js' 'hocs/**/*.js' '*.js' --write --single-quote --print-width='80' --trailing-comma='all' && xo --fix",
"precommit": "lint-staged",
"test": "xo && jest",
"lint": "prettier 'utils/**/*.js' 'components/**/*.js' 'pages/**/*.js' 'lib/**/*.js' 'hocs/**/*.js' '*.js' --write --single-quote --print-width='80' --trailing-comma='all' && xo --fix",
"precommit": "lint-staged && npm test",
"analyze": "cross-env ANALYZE=1 next build",
"dev": "cross-env NODE_ENV=development node server.js",
"start": "cross-env NODE_ENV=production next start",
Expand All @@ -16,20 +15,38 @@
},
"xo": {
"parser": "babel-eslint",
"extends": ["prettier", "prettier/react", "plugin:react/recommended"],
"env": ["browser", "node"],
"extends": [
"prettier",
"prettier/react",
"plugin:react/recommended"
],
"env": [
"browser",
"node"
],
"rules": {
"linebreak-style": 0,
"react/display-name": 0,
"react/prop-types": 0
},
"space:": 2,
"ignores": ["next.config.js"]
"ignores": [
"next.config.js"
],
"overrides": [
{
"files": "__tests__/*.test.js",
"globals": [
"describe",
"it",
"expect"
]
}
]
},
"lint-staged": {
"*.js": [
"prettier --write --single-quote --print-width=80 --trailing-comma=all",
"xo",
"git add"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would make sense to run xo and jest only for *.js file changes so can you move back xo and new jest to lint-staged options?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we add jest in lint-staged, the tests aren't being run.
To run the tests we are running the tests on precommit (see here).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I saw that, but why lint-staged can't run jest any reason?
I found this jestjs/jest#1678 so according to it we can pass jest --findRelatedTests to lint-staged to run tests for staged js files I think.

]
},
Expand Down Expand Up @@ -68,6 +85,7 @@
"eslint-config-prettier": "^2.3.0",
"eslint-plugin-react": "^7.1.0",
"husky": "^0.14.3",
"jest": "^21.2.1",
"lint-staged": "^4.0.2",
"normalize-url": "1.9.1",
"now": "8.3.10",
Expand Down