Skip to content

Instantly share code, notes, and snippets.

@octalmage
Last active September 20, 2017 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save octalmage/1f40c00ae62b662eced63c9df6a5159c to your computer and use it in GitHub Desktop.
Save octalmage/1f40c00ae62b662eced63c9df6a5159c to your computer and use it in GitHub Desktop.
Using Enzyme for Nightwatch

If we export the root returned from ReactDOM.render using something like this:

if (process.env.NODE_ENV !== 'production') {
    window.WPECP_ROOT = root;
  }

We could then import the raw ReactWrapper found in Enzyme and use it like so:

import ReactWrapper from 'enzyme/build/ReactWrapper';
const element = new ReactWrapper(WPECP_ROOT, []);
console.log(element.find(window.Router).getDOMNode());

Then we could use something like: https://www.npmjs.com/package/unique-selector to generate the selector.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment