vendredi 27 janvier 2017

_this.store.getState is not a function when testing react component with enzyme and mocha

Im trying to test a React component with enzyme and mocha as follows

import { mount, shallow } from 'enzyme';
import React from 'react';
import chai, { expect } from 'chai'
import chaiEnzyme from 'chai-enzyme'
import sinon from 'sinon'

import MyComponent from 'myComponent'

chai.user(chaiEnzyme())
describe('MyComponent', () => {
  const store = {
    id: 1
  }
  it ('renders', () => {
    const wrapper = mount(<MyComponent />, {context: {store: store}})
  })
})

haven't actually written the test as it fails at the declaration of wrapper

Error message: TypeError: _this.store.getState is not a function

No idea what the problem is and cant find anything addressing this!

Any help would be great!

Aucun commentaire:

Enregistrer un commentaire