我想使用 karma 作为我的 js 测试环境,但未能将其配置为与 ES6 一起使用。
下面是我的测试js文件:
import { shallow } from 'enzyme';
import React from 'react';
describe('<MyComponent />', () => {
it('should render three <Foo /> components', () => {
const wrapper = shallow(<MyComponent />);
expect(wrapper.find(Foo)).to.have.length(3);
});
});
Run Code Online (Sandbox Code Playgroud)
当运行 karma start 时,我会收到此错误:
未捕获的语法错误:test/features/consulting/question/question.js:1 处意外导入令牌
看来karma不支持babel编译ES6。我的配置有什么问题吗?
下面是我的 karma.conf.js:
var path = require('path');
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available …
Run Code Online (Sandbox Code Playgroud)