Skip to content

Commit

Permalink
kinda-eject for tests only :)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kent C. Dodds committed Feb 16, 2017
1 parent 65deeca commit dd6acc3
Show file tree
Hide file tree
Showing 8 changed files with 627 additions and 70 deletions.
5 changes: 5 additions & 0 deletions client/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"presets": [
"react-app"
]
}
12 changes: 12 additions & 0 deletions client/config/jest/cssTransform.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// This is a custom Jest transformer turning style imports into empty objects.
// http://facebook.github.io/jest/docs/tutorial-webpack.html

module.exports = {
process() {
return 'module.exports = {};'
},
getCacheKey() {
// The output is always the same.
return 'cssTransform'
},
}
10 changes: 10 additions & 0 deletions client/config/jest/fileTransform.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const path = require('path')

// This is a custom Jest transformer turning file imports into filenames.
// http://facebook.github.io/jest/docs/tutorial-webpack.html

module.exports = {
process(src, filename) {
return `module.exports = ${JSON.stringify(path.basename(filename))};`
},
}
28 changes: 20 additions & 8 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
"version": "0.1.0",
"private": true,
"devDependencies": {
"babel-jest": "^18.0.0",
"babel-preset-react-app": "^2.1.0",
"cross-env": "^3.1.4",
"react-scripts": "0.6.1"
"jest": "^18.1.0",
"react-scripts": "0.6.1",
"rimraf": "^2.5.4"
},
"license": "MIT",
"repository": "[email protected]:kentcdodds/testing-workshop.git",
Expand All @@ -23,22 +27,30 @@
"scripts": {
"start": "cross-env PORT=8080 react-scripts start",
"build": "react-scripts build",
"test": "cross-env CI=true react-scripts test --coverage",
"test:watch": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
"test": "jest --coverage",
"test:watch": "jest --watch",
"postinstall": "rimraf node_modules/eslint"
},
"author": "Thinkster (https://github.com/gothinkster)",
"jest": {
"testEnvironment": "jest-environment-jsdom",
"transform": {
"^.+\\.js$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.jsx$"
],
"collectCoverageFrom": [
"src/**"
],
"coverageThreshold": {
"global": {
"statements": 0.5,
"branches": 3,
"functions": 1,
"lines": 0.5
"statements": 0,
"branches": 0,
"functions": 0,
"lines": 0
}
}
}
Expand Down
632 changes: 577 additions & 55 deletions client/yarn.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ const mongoDesc = [
const concurrentTests = {
'server-tests': {
script: 'nps server.test',
color: 'bgGray.bold',
color: 'bgCyan.bold.dim',
},
'client-tests': {
script: 'nps client.test',
color: 'bgOrange.bold',
color: 'bgYellow.bold.dim',
},
}

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"license": "MIT",
"scripts": {
"start": "nps",
"test": "nps test",
"precommit": "nps validate",
"setup": "node ./scripts/verify.js && node ./scripts/install && nps validate"
},
Expand Down
5 changes: 0 additions & 5 deletions scripts/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ function spawnInstall(cwd) {
if (finishedCount < 3) {
return
}
// now that we have installed deps, we can require rimraf here
// remove the eslint version from the client
// because it messes things up when we actually want to use
// the eslint version from the main package
require('rimraf').sync(path.resolve(__dirname, '../client/node_modules/eslint'))
console.log('all dependencies have been installed')
}
}

0 comments on commit dd6acc3

Please sign in to comment.