【发布时间】:2018-04-19 19:00:45
【问题描述】:
我正在尝试使用 React 配置 AVAjs。
这是我在 package.json 中的 AVA 配置:
"ava": {
"files": [
"test/**/*.spec.js"
],
"sources": [
"**/*.{js,jsx}",
"!dist/**/*"
],
"concurrency": 4,
"failFast": true,
"failWithoutAssertions": false,
"tap": true,
"compileEnhancements": false,
"require": [
"@babel/core",
"@babel/register",
"@babel/polyfill"
],
"babel": {
"testOptions": {
"babelrc": false,
"testOptions": {
"presets": [
["@babel/preset-env", {
"targets": {
"node": "current"
}
}],
["@babel/preset-react", {
"pragma": "dom",
"pragmaFrag": "DomFrag",
"throwIfNamespace": false
}]
]
}
}
}
}
还有我的测试文件:
import test from 'ava';
import React from 'react';
import Enzyme, { shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import Other from '../assets/js/components/Other';
Enzyme.configure({ adapter: new Adapter() });
test('has a .Foo class name', (t) => {
const wrapper = shallow(<Other />);
t.pass(wrapper);
});
无效:
{ presets: [{option: value}] }有效:{ presets: [['presetName', {option: value}]] }
谁能帮帮我?
【问题讨论】: