Created
November 2, 2020 18:11
-
-
Save mainfraame/58304874ed85b356012fc7c4f8c1216c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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