Jef*_*ege 4 reactjs jestjs visual-studio-code
我们正在 vscode 中构建一个 React 应用程序,使用 jest 来运行单元测试。
\n\n当我们运行测试时,我们会看到 node_modules 中文件的编译器警告。
\n\nPASS src/components/Common/IonicWrappers/__tests__/KorSelect.test.tsx\nPASS src/components/Common/IonicWrappers/__tests__/KorHeader.test.tsx\n\xe2\x97\x8f Console\n\nconsole.warn node_modules/react-dom/cjs/react-dom.development.js:11494\nWarning: componentWillReceiveProps has been renamed, and is not recommended for use.\nRun Code Online (Sandbox Code Playgroud)\n\n我们使用 运行测试npm test,其中 package,json 包含:
"scripts": {\n "start": "react-scripts start",\n "build": "react-scripts build",\n "test-react": "react-scripts test --transformIgnorePatterns \\"node_modules/(?!(@ionic|ionicons|capacitor-data-storage-sqlite))\\"",\n "test": "npm run test-react",\n [...]\n},\nRun Code Online (Sandbox Code Playgroud)\n\n.vscode/settings.json 是:
\n\n{\n "jest.pathToJest": "--runInBand --no-cache --watchAll=false --transformIgnorePatterns=\'node_modules/(?!(@ionic|ionicons|capacitor-data-storage-sqlite))\'",\n "jest.runAllTestsFirst": false,\n "jest.enableInlineErrorMessages": false,\n "jest.pathToConfig": "./node_modules/.bin/react-scripts",\n "jestrunner.jestCommand": "npm test --runInBand --no-cache --watchAll=false --transformIgnorePatterns=\'node_modules/(?!(@ionic|ionicons|capacitor-data-storage-sqlite))\'"\n}\nRun Code Online (Sandbox Code Playgroud)\n\n现在这些警告很有价值,我们确实需要知道node_modules中有我们可能想要考虑更新的包,但我不需要在每次测试运行时都看到它们。
\n\n而且它们使得很难看到测试的实际结果。
\n\n无论如何,有什么配置可以抑制它们吗?
\n| 归档时间: |
|
| 查看次数: |
7719 次 |
| 最近记录: |