我想用带有 typescript 的 react 来设置 jest 。
每当我运行npm test它都会出错。
npm test 给了我以下错误:
开箱即用,Create React App 仅支持覆盖这些 Jest 选项:
• collectCoverageFrom • coverageReporters • coverageThreshold
• snapshotSerializers。Create React App 目前不支持 package.json Jest 配置中的这些选项:
• 转换 • testRegex • moduleFileExtensions
如果您希望覆盖其他 Jest 选项,则需要从默认设置中弹出。您可以通过运行 npm run eject 来实现,但请记住,这是一种单向操作。您还可以向 Create React App 提交问题,以讨论支持更多开箱即用的选项。
我不想弹出,我还希望以下选项起作用
• 转换
• testRegex
• moduleFileExtensions
我该怎么办??
我的 package.json 文件如下
{
"name": "appname",
"version": "0.1.0",
"private": true,
"dependencies": {
"jest-cli": "^22.3.0",
"jest-enzyme": "^4.2.0",
"react": "^16.2.0",
"react-scripts": "1.1.1" …Run Code Online (Sandbox Code Playgroud) import {theme} from "./themes";
const App = () => (
<ThemeProvider theme={theme}>
<ErrorBoundary showError>
<Provider store={store}>
<Router>
<switch>
<Route path="/page1" exact component={Page} />
<Route path="/notfound" component={NotFound} />
</switch>
</Router>
</Provider>
</ErrorBoundary>
</ThemeProvider>
export default hot(module)(App);
Run Code Online (Sandbox Code Playgroud)
现在,在我的页面组件中,我的道具不包括主题,即 props.theme 未定义
有人能告诉我哪里出了问题吗?
我的页面组件有减速器、位置、匹配道具,但没有主题