jest自动化测试遇到的一些报错信息及解决方案

1. Plugin 0 specified in "C:\\work\\New\\In-internet\\next\\babel.js" procided an invalid property of "default". 如图:

 

 

 

 

 

 

 

 

 

 

 

 

 

解决:.babelrc中缺少test配置

"env": {
    "test": {
      "presets": [["next/babel", { "preset-env": { "modules": "commonjs" }}]]
    }
  }

 

2.  Unfortunately nesting is not supported by styled-jsx . 如图:

解决: 配置styled-jsx的plugins: styled-jsx-plugin-postcss

"env": {
    "test": {
      "presets": [["next/babel", { "preset-env": { "modules": "commonjs" }, "styled-jsx": {
        "plugins": [
          "styled-jsx-plugin-postcss"
        ]
      } }]]
    }
  }

 

3. Could not find "store" in either the context or props, 如图:

因为组件用了connect(), 组件结构如下:

import { connect } from 'react-redux'class StepStatus extends Component { /* ... */ }
​
export default connect(mapStateToProps)(StepStatus)

解决: 

import { connect } from 'react-redux'// Use named export for unconnected component (for tests)
export class StepStatus extends Component { /* ... */ }
​
// Use default export for the connected component (for app)
export default connect(mapStateToProps)(StepStatus)

 用{}引用, 如 import { StepStatus } from './StepStatus'

 

4. eslint的错误

(1)[eslint] 'enzyme' should be listed in the project's dependencies, not devDependencies. (import/no-extraneous-dependencies)

 解决:在.eslintrc的rules加  "import/no-extraneous-dependencies": ["error", {"devDependencies": true}]

(2)[eslint] Using exported name 'StepStatus' as identifier for default export. (import/no-named-as-default)

 解决:在.eslintrc的rules加  'import/no-named-as-default': 0

 

 

转载于:https://www.cnblogs.com/susu8/p/9519157.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值