账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    在 Karma + jasmine 中 enzyme 的 setup 文件应该写在什么地方
    65
    0

    昨天将项目更新到 React v16.0 ,但是 CI 构建出现如下问题:

     Error:
                  Enzyme Internal Error: Enzyme expects an adapter to be configured, but found none. To
                  configure an adapter, you should call `Enzyme.configure({ adapter: new Adapter() })`
                  before using any of Enzyme's top level APIs, where `Adapter` is the adapter
                  corresponding to the library currently being tested. For example:
                  import Adapter from 'enzyme-adapter-react-15';
                  To find out more about this, see http://airbnb.io/enzyme/docs/installation/index.html

    查阅文档发现 Enzyme 3.0 Api 发生变化

    按照官方的说法,需要在 setup file 中添加如下代码。

    // http://airbnb.io/enzyme/docs/installation/react-16.html
    // setup file
    import { configure } from 'enzyme';
    import Adapter from 'enzyme-adapter-react-16';
    
    configure({ adapter: new Adapter() });

    那么问题来了,应该添加到什么地方?

    尝试添加到每个测试文件前,没有成功
    尝试添加到 `karma.conf.js` 的 `files: []` 中,也没有成功。
    2
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 热血无赖 普通会员 1楼
      502 Bad Gateway

      502 Bad Gateway


      nginx
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部