Cypress: Enzyme setup, described in related example not working properly

Created on 7 Mar 2018  路  3Comments  路  Source: cypress-io/cypress

  • Operating System: MacOS 10.13.3
  • Cypress Version: 2.1.0
  • Browser Version: 64.0.3282.186

Is this a Feature or Bug?

Bug

Current behavior:

Following https://github.com/cypress-io/cypress-example-recipes/blob/master/examples/unit-testing__react-enzyme/cypress/integration/unit-test-react-enzyme-spec.js#L24 commentary and moving configure call to support/index.js leads to following error, while performing the test:

Enzyme Internal Error: Enzyme expects an adapter to be configured, but found none. To
      configure an adapter, you should call `Enzyme.configure({ adapter: new Adapter() })`
      before using any of Enzyme's top level APIs, where `Adapter` is the adapter
      corresponding to the library currently being tested. For example:

      import Adapter from 'enzyme-adapter-react-15';

      To find out more about this, see http://airbnb.io/enzyme/docs/installation/index.html

Desired behavior:

Correct enzyme configuration

How to reproduce:

Move enzyme configuration code to support/index.js instead of a test spec file

Test code:

Not related to a test code, obviously

Additional Info (images, stack traces, etc)

All 3 comments

This isn't working because support/index.js is served separately from your spec files. Because they are two different bundles they don't see one another.

What we meant was - move the configure to a support/util.js which is required specifically by each spec.

const utils = require('../support/utils')
utils.configureEnzyme() // something like this

describe(..., () => {
  it(...)
})

I talk about this in the video about halfway through (I think).

The default support file: support/index.js is just a <script> bundle served before your specs. It's supposed to handle global configuraiton.

https://www.youtube.com/watch?v=5XQOK0v_YRE

@brian-mann oh, I see. Thanks for a fast feedback and many thanks for such a brilliant piece of software!

Was this page helpful?
0 / 5 - 0 ratings