Bug
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
Correct enzyme configuration
Move enzyme configuration code to support/index.js
instead of a test spec file
Not related to a test code, obviously
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.
@brian-mann oh, I see. Thanks for a fast feedback and many thanks for such a brilliant piece of software!