2

When I execute the cypress test

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;
  });
});

For the source code of Product

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>
    )
  }
}

And the productlib

import React from 'react'
export default class Product extends React.Component { }

Then I get following error in Cypress Error: Cannot find module './preprocessor' from >'/Users/stein/node_modules/parse5/lib/tokenizer'

How do I fix this error?

stein korsveien
  • 1,047
  • 5
  • 13
  • 35
  • I am not sure if this relates to your error message, but your test does not look like a Cypress test. Would expect at least one `cy.` command. –  Jul 07 '18 at 20:55
  • I fixed this error by installing ezym: npm i --save-dev enzyme – stein korsveien Jul 09 '18 at 13:02

0 Answers0