#reactjs #jestjs #create-react-app #fsevents
#reactjs #jestjs #create-react-app #fsevents
Вопрос:
Я получаю указанную выше ошибку при запуске jest v23 в monorepo. Пакет, в котором я запускаю jest, построен на CRA и craco. Package.json моего CRA
{
"name": "@sprinklr/chat-web-client",
"version": "0.1.0",
"dependencies": {
"@emotion/core": "^10.0.5",
"@emotion/styled": "^10.0.5",
"@sentry/browser": "^5.8.0",
"@sentry/integrations": "^5.8.0",
"@sprinklr/chat-constants": "2.0.0",
"@sprinklr/chat-entities": "2.0.0",
"@sprinklr/chat-utils": "2.0.0",
"@sprinklr/rest-client": "2.0.0",
"azure-storage": "^2.10.3",
"bluebird": "^3.4.0",
"classnames": "^2.2.6",
"core-js": "^3.0.1",
"emotion": "^10.0.2",
"emotion-theming": "^10.0.5",
"formik": "^1.3.2",
"immutability-helper": "^2.8.1",
"jstz": "^2.1.1",
"lodash": "^4.17.4",
"polished": "^2.3.0",
"prop-types": "^15.5.7",
"react": "^16.8.6",
"react-autosize-textarea": "^6.0.0",
"react-dom": "^16.8.6",
"react-frame-component": "^4.0.2",
"react-redux": "7.2.0",
"react-router": "^4.3.1",
"react-router-dom": "^4.3.1",
"react-scripts": "2.1.7",
"react-transition-group": "^2.5.3",
"react-use": "^14.1.1",
"redux": "^4.0.0",
"redux-logger": "^3.0.6",
"redux-saga": "^1.0.1",
"reselect": "^4.0.0",
"scriptjs": "^2.5.8",
"shortid": "^2.2.14",
"styled-system": "^3.0.2",
"typesafe-actions": "^2.0.4",
"validate.js": "^0.13.1"
},
"scripts": {
"precommit": "pretty-quick --staged",
"start": "sh internals/build/build-packages.sh amp;amp; craco start --workspace",
"prebuild": "NODE_ENV=production babel-node internals/build/tools/run prebuild",
"build": "sh internals/build/build.sh",
"analyze": "source-map-explorer build/static/js/main.*",
"eject": "react-scripts eject",
"docz:dev": "docz dev",
"docz:build": "docz build",
"static": "NODE_ENV=production babel-node internals/build/tools/run static/index",
"widget": "NODE_ENV=production babel-node internals/build/tools/run widget/index",
"i18n": "sh internals/i18n/index.sh",
"lint": "eslint src",
"format": "npm run prettier -- --write",
"prettier": "prettier "**/*. (js|jsx|json|yml|yaml|css|less|scss|ts|tsx|md|graphql|mdx)"",
"validate": "npm run lint amp;amp; npm run prettier -- --list-different",
"test": "craco test --workspace --env=jsdom",
"test-watch": "npm run test -- --watch",
"test-coverage": "npm run test -- --coverage",
"test-update": "npm run test -- --updateSnapshot"
},
"devDependencies": {
"@babel/cli": "7.2.3",
"@babel/core": "7.2.2",
"@babel/node": "7.2.2",
"@babel/preset-env": "^7.3.1",
"@craco/craco": "^3.5.0",
"@emotion/babel-preset-css-prop": "^10.0.7",
"@sprinklr/chat-types": "2.0.0",
"@testing-library/jest-dom": "4.2.4",
"@testing-library/react": "^9.4.0",
"@types/bluebird": "^3.5.26",
"@types/classnames": "^2.2.7",
"@types/jest": "26.0.0",
"@types/lodash": "^4.14.118",
"@types/node": "^11.13.7",
"@types/react": "^16.8.14",
"@types/react-dom": "^16.8.4",
"@types/react-intl": "^2.3.15",
"@types/react-redux": "^7.1.0",
"@types/react-router": "^4.4.2",
"@types/react-textarea-autosize": "^4.3.3",
"@types/react-transition-group": "^2.0.15",
"@types/redux-logger": "^3.0.6",
"@types/scriptjs": "^0.0.2",
"@types/shortid": "^0.0.29",
"@types/styled-system": "^3.0.8",
"aws-sdk": "^2.392.0",
"babel-plugin-lodash": "^3.3.4",
"babel-plugin-named-asset-import": "^0.2.3",
"babel-plugin-react-intl": "^3.0.1",
"babel-plugin-react-intl-auto": "^1.6.0",
"babel-preset-react-app": "^7.0.0",
"cheerio": "^1.0.0-rc.2",
"docz": "^0.12.15",
"eslint-plugin-prettier": "^2.6.2",
"glob": "^7.1.2",
"husky": "^0.14.3",
"node-sass-chokidar": "^1.3.0",
"prettier": "1.13.7",
"pretty-quick": "^1.6.0",
"react-intl": "^2.8.0",
"source-map-explorer": "^1.5.0",
"terser": "3.16.1",
"ts-jest": "26.1.1",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.16.0",
"tslint-react-hooks": "^1.1.0",
"typescript": "3.4.5",
"typescript-styled-plugin": "^0.13.0",
"webpack-merge": "^4.1.4"
},
"optionalDependencies": {
"fsevents": "1.2.4"
},
"browserslist": [
">1%",
"last 4 versions",
"Firefox ESR",
"not ie < 11"
]
}
Я проверил свои node_modules, и у него установлены fsevents. Все еще получаю ошибку. Наиболее распространенным решением, которое я нашел, была переустановка node_modules после удаления yarn.блокировка, но это решение не работает для меня. Ни установка watchman не сработала.
Я использую jestConfig самого CRA
Ответ №1:
Решил эту проблему, установив brew, а затем выполнив brew install watchman
на моем mac.