Feature/add jest configs ref: #1383 (#1385)

* add deps for testing

* feat(tests): add jest configs

* uncomment module directories path
This commit is contained in:
Larry Botha
2019-07-15 12:25:32 -05:00
committed by Tanner Linsley
parent 4a3929cd50
commit bc3ea07c3e
10 changed files with 9418 additions and 5015 deletions

View File

@@ -1,6 +1,9 @@
{
"parser": "babel-eslint",
"extends": ["react-app", "prettier"],
"plugins": [
"react-hooks"
],
"env": {
"es6": true
},
@@ -16,4 +19,4 @@
"version": "latest"
}
}
}
}

View File

@@ -0,0 +1,17 @@
const path = require('path');
module.exports = {
moduleDirectories: [
'node_modules',
/*
* make 'test/utils' available in tests, e.g.
*
* const {myModule} = require('utils/my-test-helper')
*/
__dirname,
],
rootDir: path.resolve(__dirname, '../..'),
roots: ['<rootDir>/src', __dirname],
};

View File

@@ -0,0 +1,13 @@
const {rootDir} = require('./jest.common');
module.exports = {
rootDir,
displayName: 'lint',
runner: 'jest-runner-eslint',
testMatch: ['<rootDir>/src/**/*.js'],
testPathIgnorePatterns: ['node_modules', 'coverage', 'dist', '.test.js'],
};

View File

@@ -0,0 +1,15 @@
const commonConfig = require('./jest.common');
module.exports = {
...commonConfig,
displayName: 'unit',
coverageDirectory: '../../coverage',
testMatch: ['<rootDir>/tests/**/*.js'],
transform: {
// '^.+\\.js$': '<rootDir>/node_modules/babel-jest',
},
};

View File

16
jest.config.js Normal file
View File

@@ -0,0 +1,16 @@
const path = require('path');
const lintProject = require('./configs/tests/jest.lint');
const unitProject = require('./configs/tests/jest.unit');
module.exports = {
...require('./configs/tests/jest.common'),
projects: [lintProject, unitProject],
watchPlugins: [
'jest-watch-typeahead/filename',
'jest-watch-typeahead/testname',
'jest-watch-select-projects',
],
};

10514
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -18,14 +18,14 @@
"module": "dist/index.es.js",
"jsnext:main": "dist/index.es.js",
"scripts": {
"test": "cross-env CI=1 react-scripts test --env=jsdom",
"test:watch": "react-scripts test --env=jsdom",
"test": "is-ci 'test:ci' 'test:dev'",
"test:dev": "jest --watch",
"test:ci": "jest",
"build": "rollup -c",
"start": "rollup -c -w",
"prepare": "yarn build",
"release": "yarn publish",
"releaseNext": "yarn publish --tag next",
"lint": "eslint 'src/**/*.js'"
"releaseNext": "yarn publish --tag next"
},
"files": [
"src/",
@@ -47,6 +47,7 @@
"@babel/preset-react": "^7.0.0",
"@babel/runtime": "^7.2.0",
"@svgr/rollup": "^4.1.0",
"@testing-library/react": "^8.0.4",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "9.x",
"cross-env": "^5.1.4",
@@ -64,8 +65,12 @@
"eslint-plugin-react": "7.x",
"eslint-plugin-react-hooks": "1.5.0",
"eslint-plugin-standard": "^4.0.0",
"husky": "^3.0.0",
"lint-staged": "^9.0.0",
"is-ci-cli": "^1.1.1",
"jest": "^24.8.0",
"jest-cli": "^24.8.0",
"jest-runner-eslint": "^0.7.4",
"jest-watch-select-projects": "^0.1.2",
"jest-watch-typeahead": "^0.3.1",
"rollup": "^0.68.0",
"rollup-plugin-babel": "^4.1.0",
"rollup-plugin-commonjs": "^9.1.3",

0
tests/.gitkeep Normal file
View File

3836
yarn.lock

File diff suppressed because it is too large Load Diff