Skip to content

Instantly share code, notes, and snippets.

@mainfraame
Created November 2, 2020 18:11
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 mainfraame/58304874ed85b356012fc7c4f8c1216c to your computer and use it in GitHub Desktop.
Save mainfraame/58304874ed85b356012fc7c4f8c1216c to your computer and use it in GitHub Desktop.
import { Given, When, Then } from 'cucumber';
import { act } from 'react-dom/test-utils';
import Element from './path/to/Element';
Given(/I go to (.*)$/, function(link) {
window.location.hash = `#/${link}`;
});
When(/I click the (\S+) button$/, function(id) {
const $element = new Element({id});
element.click(); // <- this method already wraps the click inside of act for you.
});
Then(/the (\S+) button is (visible|not visible)$/, function(name, state) {
const $element = new Element({id});
expect($element.isInDom())
.toEqual(state === 'visible')
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment