Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 使用jest酶进行单元测试返回SyntaxError:意外标记_Node.js_Unit Testing_Enzyme_Jestjs - Fatal编程技术网

Node.js 使用jest酶进行单元测试返回SyntaxError:意外标记

Node.js 使用jest酶进行单元测试返回SyntaxError:意外标记,node.js,unit-testing,enzyme,jestjs,Node.js,Unit Testing,Enzyme,Jestjs,我正在尝试对React进行单元测试。我在用玩笑和酶 这是我的宝贝 { "presets": ["es2015", "react", "airbnb"] } 我的测试文件: import React from 'react'; import { shallow, mount, render } from 'enzyme'; import Home from './Home/Home.js'; describe('Home', function() { it('should r

我正在尝试对React进行单元测试。我在用玩笑和酶

这是我的宝贝

{
    "presets": ["es2015", "react", "airbnb"]
}
我的测试文件:

import React from 'react';
import { shallow, mount, render } from 'enzyme';

import Home from './Home/Home.js';

describe('Home', function() {
    it('should render without throwing an error', function() {
        expect(shallow(<Home />).contains(<div className="columns is-mobile"></div>)).toBe(true);
    });
});

有人能帮我看看为什么我的测试无法运行吗?

您可以尝试改用ES6代理。通过npm安装,使用

npm install --save-dev identity-obj-proxy
然后在jest的配置文件中,将css的模块映射器更改为如下内容

"\\.(css|less)$": "identity-obj-proxy"

有关详细信息,请参阅。

我将在有机会时尝试此解决方案,提前感谢!
"\\.(css|less)$": "identity-obj-proxy"