Closed randytorres closed 6 years ago
Can you provide a full repo? It's hard to tell what's wrong without seeing any source code.
Its a private repo so i cant but theres no custom configuration related to jest. Heres our package.json and an image of the folder structure if that helps. Should it automatically exclude anything outside of the src folder?
{
"name": "",
"license": "UNLICENSED",
"private": true,
"version": "0.1.0",
"homepage": "",
"dependencies": {
"animated": "^0.2.1",
"apollo-boost": "^0.1.4",
"apollo-cache-inmemory": "^1.1.12",
"apollo-cache-persist": "^0.1.1",
"apollo-client": "^2.2.8",
"apollo-link": "^1.2.1",
"apollo-link-http": "^1.5.3",
"apollo-link-state": "^0.4.1",
"classnames": "^2.2.5",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1",
"final-form": "^4.4.0",
"final-form-set-field-data": "^1.0.1",
"graphql": "^0.13.2",
"graphql-tag": "^2.8.0",
"js-cookie": "^2.2.0",
"json-2-csv": "^2.2.0",
"link-to-inbox": "^1.2.0",
"lodash": "^4.17.5",
"material-ui": "^0.19.4",
"moment": "^2.19.1",
"numbro": "^2.0.6",
"object-diff": "^0.0.4",
"object-hash": "^1.2.0",
"pre-commit": "^1.2.2",
"prop-types": "^15.6.0",
"query-string": "^5.0.1",
"react": "^16.2.0",
"react-animate-on-scroll": "^1.3.2",
"react-apollo": "^2.1.1",
"react-dom": "^16.0.0",
"react-final-form": "^3.1.5",
"react-flexbox-grid": "^1.1.5",
"react-intl": "^2.4.0",
"react-loadable": "^5.3.1",
"react-recaptcha": "^2.3.5",
"react-router-config": "^1.0.0-beta.4",
"react-router-dom": "^4.2.0",
"react-router-prop-types": "^0.0.2",
"react-scripts": "^1.0.14",
"react-stripe-elements": "^1.3.2",
"react-test-renderer": "^16.2.0",
"react-toastify": "^4.0.1",
"react-transition-group": "^1.2.0",
"recordrtc": "^5.4.6",
"source-map-explorer": "^1.5.0",
"uuid": "^3.2.1"
},
"scripts": {
"analyze": "source-map-explorer build/static/js/main.*",
"build-css": "node-sass-chokidar src/ -o src/",
"watch-css": "npm run build-css && node-sass-chokidar --include-path=src/modules/core/styles src/ -o src/ --watch --recursive",
"start-js": "react-scripts start --host 0.0.0.0",
"start": "PORT=80 npm-run-all -p watch-css start-js",
"build": "npm run build-css && react-scripts build",
"test": "react-scripts test --env=jsdom --verbose",
"coverage": "react-scripts test --coverage --env=jsdom --no-cache",
"deploy": "npm run build && gh-pages -d build",
"lint": "eslint ./src",
"ratchet": "jest-coverage-ratchet",
"styleguide": "npm-run-all -p watch-css styleguidist",
"styleguidist": "styleguidist server",
"styleguide-build": "styleguidist build"
},
"devDependencies": {
"eslint": "4.9.0",
"eslint-config-airbnb": "16.1.0",
"eslint-plugin-import": "2.7.0",
"eslint-plugin-jsx-a11y": "6.0.2",
"eslint-plugin-react": "7.4.0",
"gh-pages": "^1.0.0",
"ip": "^1.1.5",
"jest-coverage-ratchet": "^0.2.3",
"node-sass-chokidar": "0.0.3",
"npm-run-all": "^4.0.2",
"react-router-test-context": "^0.1.0",
"react-styleguidist": "^7.0.17"
},
"jest": {
"coverageThreshold": {
"global": {
"lines": 39.7,
"statements": 29.79,
"functions": 27.12,
"branches": 23.75
}
},
"coverageReporters": [
"json-summary",
"text",
"text-summary"
]
}
}
Thanks for the extra information. What is the output of the test run and which tests were run but wasn't suppose to? I don't see any other directories in the screenshot.
I had to remove the tests but they were in the root directory like this
.snapguidist
-- __snapshots__
---- test1.snap
---- test2.snap
and the output was 10 obsolete snapshot files found, press u to remove them.
It appears the config for jest has roots
set to the root of the project.
I suspect this is to be more lenient on how users want to organize their tests (in src/...
, vs in a separate tests directory in the root for example).
This should be strict on test matching in v2:
testMatch: [
'<rootDir>/src/**/__tests__/**/*.{js,jsx}',
'<rootDir>/src/**/?(*.)(spec|test).{js,jsx}',
],
Please let us know if this still doesn't work right.
I'm using react-scripts "1.1.4" and running
yarn test
is including a folder outside of the src directory. I thought based on this issue that was fixed https://github.com/facebook/create-react-app/issues/544. Is this a bug or is there a way to exclude anything outside of the src folder.