昨天我升级我做出反应的项目v16.0,但我发现酶有一些问题酶安装文件应该写在哪里?
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
at validateAdapter (spec/components/page_components/SongListItem/index.spec.js:9:1141986)
at getAdapter (spec/components/page_components/SongListItem/index.spec.js:9:323041)
at new ReactWrapper (spec/components/page_components/SongListItem/index.spec.js:9:622193)
at mount (spec/components/page_components/SongListItem/index.spec.js:9:2025476)
at UserContext.<anonymous> (spec/components/page_components/SongListItem/index.spec.js:9:1235741)
而且我发现在官方website
// setup file
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
configure({ adapter: new Adapter() });
一个解决方案,但我有一个问题:酶设置文件应该写在哪里?在每个测试文件前面?
我想上面的代码添加到测试文件之一,但仍有一个问题
Internal error: attempt to prepend statements in disallowed (non-array) context at C:/Users/killer/workspace/react/NetEase-Cloud-Music-Web/spec/components/page_components/SongListItem/index.spec.js
This是我的项目的