jeudi 23 février 2017

React testing error: It looks like you called `mount()` without a global document being loaded

index.spec.js file:

import React from 'react';
import { mount } from 'enzyme';
import Header from './';
import { expect } from 'chai';

describe('header component', () => {
  let renderedOutput;
  beforeEach(() => {
    renderedOutput = mount(<Header />)
  })

  describe('initial state', () => {
    it('renders the header', () => {
      expect(renderedOutput).to.exist();
    });
    it('renders the header', () => {
      expect(renderedOutput).to.be.present();
    });
  })
});

Run the spec and it fails with: Error: It looks like you called mount() without a global document being loaded.

I've read something about jsdom but wasn't sure why to add that. anyone explain what I'm doing wrong?

Aucun commentaire:

Enregistrer un commentaire