score:1

Accepted answer

tests/index.tsx

import * as react from 'react'
import { expect as expect1 } from 'chai';

import indexpage from '../pages/index'

import {/*mount,*/ shallow} from 'enzyme' 

const setup1 = (data) => {
  return shallow(<indexpage {...data} />);
}
let wrapper;

describe('props check', () => {

  beforeeach(() => {
      wrapper = setup1(allpostsdata={[]});
  });

  it('should render an `.icon-stars`', () => {
    expect1(wrapper.find('.icon-stars')).to.have.length(1);
  });

});

you have to pass props inside the testing component & use

import * as react from 'react'

in pages/index.tsx for rendering react components


Related Query

More Query from same tag