当我执行柏树测试时
import React from 'react';
import ReactDOM from 'react-dom';
import { configure, shallow } from 'enzyme';
import { expect } from 'chai';
import ProcutList from '../../src/components/ProductList';
import Product from '../../src/components/Product'
import Adapter from 'enzyme-adapter-react-16'
configure({ adapter: new Adapter() });
describe('ProductList component testing', () => {
it('Should display one product in a productlist' , ()=> {
const wrapper = shallow(<ProductList />);
const item =wrapper.find('div[class="ui unstackable items"]');
const product = item.find('Product')
expect(product).to.exist;
});
});
对于产品的源代码
import React from 'react'
export default class Product extends React.Component {
render () {
return (
<div className = 'item'>
<div className = 'image'>
<img src='./images/Banana-Snowboard.png' alt="Snow Board"/>
</div>
<div className = 'middel aligned content'>
<div className = 'description'>
<a>Snow Board</a>
<p>Cool Snow Board</p>
</div>
<div className = 'extra'>
<span>Submitted by:</span>
<img className = 'ui avatar image' src= './images/avatar.png' alt="Avatar" />
</div>
</div>
</div>
)
}
}
和产品库
import React from 'react'
export default class Product extends React.Component { }
然后我在 Cypress 错误中收到以下错误:无法从 >'/Users/stein/node_modules/parse5/lib/tokenizer' 找到模块 './preprocessor'
如何修复此错误?