【发布时间】:2019-08-28 21:02:51
【问题描述】:
我们正在 vscode 中构建一个 react 应用,使用 jest 运行单元测试。
当我们运行测试时,我们会看到 node_modules 中文件的编译器警告。
PASS src/components/Common/IonicWrappers/__tests__/KorSelect.test.tsx
PASS src/components/Common/IonicWrappers/__tests__/KorHeader.test.tsx
● Console
console.warn node_modules/react-dom/cjs/react-dom.development.js:11494
Warning: componentWillReceiveProps has been renamed, and is not recommended for use.
我们使用npm test 运行我们的测试,其中 package,json 包含:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test-react": "react-scripts test --transformIgnorePatterns \"node_modules/(?!(@ionic|ionicons|capacitor-data-storage-sqlite))\"",
"test": "npm run test-react",
[...]
},
而 .vscode/settings.json 是:
{
"jest.pathToJest": "--runInBand --no-cache --watchAll=false --transformIgnorePatterns='node_modules/(?!(@ionic|ionicons|capacitor-data-storage-sqlite))'",
"jest.runAllTestsFirst": false,
"jest.enableInlineErrorMessages": false,
"jest.pathToConfig": "./node_modules/.bin/react-scripts",
"jestrunner.jestCommand": "npm test --runInBand --no-cache --watchAll=false --transformIgnorePatterns='node_modules/(?!(@ionic|ionicons|capacitor-data-storage-sqlite))'"
}
现在这些警告很有价值,我们确实需要知道 node_modules 中有我们可能要考虑更新的包,但我不需要在每次测试运行时都看到它们。
而且他们很难看到测试的实际结果。
有没有配置东西来抑制它们?
【问题讨论】:
标签: reactjs visual-studio-code jestjs