我试图通过以下方式为react-scripts设置自定义的jest.config:
"test": "react-scripts test -- --config=jest.config.js",
值得一提的是,我有一个单体存储库。
但是这导致了以下错误:
Invalid testPattern --config=jest.config.js|--watch|--config|{"roots":["<rootDir>/src"],"collectCoverageFrom":["src/**/*.{js,jsx,ts,tsx}","!src/**/*.d.ts"],"setupFiles":["/var/www/tractable/property-estimating/node_modules/react-app-polyfill/jsdom.js"],"setupFilesAfterEnv":["<rootDir>/src/setupTests.ts"],"testMatch":["<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}","<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}"],"testEnvironment":"jsdom","testRunner":"/var/www/tractable/property-estimating/node_modules/jest-circus/runner.js","transform":{"^.+\\.(js|jsx|mjs|cjs|ts|tsx)$":"/var/www/tractable/property-estimating/node_modules/react-scripts/config/jest/babelTransform.js","^.+\\.css$":"/var/www/tractable/property-estimating/node_modules/react-scripts/config/jest/cssTransform.js","^(?!.*\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)":"/var/www/tractable/property-estimating/node_modules/react-scripts/config/jest/fileTransform.js"},"transformIgnorePatterns":["[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs|cjs|ts|tsx)$","^.+\\.module\\.(css|sass|scss)$"],"modulePaths":["/var/www/tractable/property-estimating/frontend/claim-handler/src"],"moduleNameMapper":{"^react-native$":"react-native-web","^.+\\.module\\.(css|sass|scss)$":"identity-obj-proxy"},"moduleFileExtensions":["web.js","js","web.ts","ts","web.tsx","tsx","json","web.jsx","jsx","node"],"watchPlugins":["jest-watch-typeahead/filename","jest-watch-typeahead/testname"],"resetMocks":true,"rootDir":"/var/www/tractable/property-estimating/frontend/claim-handler"}|--env|/var/www/tractable/property-estimating/node_modules/jest-config/node_modules/jest-environment-jsdom/build/index.js supplied. Running all tests instead.
版本
"react-scripts": "4.0.3",
--
。 - Amit Singh