Skip to content

fix: Undefined function When #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 23 additions & 21 deletions cypress/cypressPhrases.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const { when, then } = require('cypress-cucumber-preprocessor/lib/resolveStepDefinition')

const {
scroll,
click,
Expand All @@ -24,75 +26,75 @@ const REGEX = require('../common/regex');

module.exports = () => {
// ex: I scroll to the bottom the "Modal"
When(REGEX.SCROLL, scroll);
when(REGEX.SCROLL, scroll);

// ex: I click on the "Button"
// I click "Save"
// I click on "Save" inside the "Modal"
// I click on "Button" inside the "Modal" containing "Save"
When(REGEX.CLICK, click);
when(REGEX.CLICK, click);


// ex: I type "toli" into the "Username Input"
// I type "toli" into "Username"
// I type "toli" into the "Username Input" on the "SignIn form"
When(REGEX.TYPE, type);
when(REGEX.TYPE, type);

// ex: When I replace the contents of "Username" with "toli"
// When I replace the contents of "Username" inside of the "Login Modal" with "toli"
When(REGEX.REPLACE, replace);
when(REGEX.REPLACE, replace);

// ex: I open the "Login Screen"
When(REGEX.OPEN, open);
when(REGEX.OPEN, open);

// @TODO: Figure out while default way isn't working
When(REGEX.WAIT_FOR_RESULTS, waitForResults);
when(REGEX.WAIT_FOR_RESULTS, waitForResults);

// use only in cases where Cypress functions can't be used
When(REGEX.WAIT_SECONDS, (seconds) => {
when(REGEX.WAIT_SECONDS, (seconds) => {
cy.wait(seconds * 1000);
});

// This is experimental and not part of the official API
When(REGEX.DRAG_ABOVE, dragAbove);
when(REGEX.DRAG_ABOVE, dragAbove);

When(REGEX.TAKE_SNAPSHOT, takeSnapshot);
when(REGEX.TAKE_SNAPSHOT, takeSnapshot);

When(REGEX.TAKE_EL_SNAPSHOT, takeElSnapshot);
when(REGEX.TAKE_EL_SNAPSHOT, takeElSnapshot);

When(REGEX.TAKE_SNAPSHOT_NAMED, takeNamedSnapshot)
when(REGEX.TAKE_SNAPSHOT_NAMED, takeNamedSnapshot)

// ex: I should be on the "Login Screen"
Then(REGEX.ON_PAGE, onPage);
then(REGEX.ON_PAGE, onPage);

// ex: I should be redirected to the "Login Screen"
Then(REGEX.REDIRECTED_TO, redirectedTo);
then(REGEX.REDIRECTED_TO, redirectedTo);

// I should see 3 "Buttons" in "Modal"
Then(REGEX.N_ELEMENTS, nElements);
then(REGEX.N_ELEMENTS, nElements);

// ex: I should see "Press Me" on the "Button" inside the "Modal"
Then(REGEX.TEXT_ON_EL, textOnEl);
then(REGEX.TEXT_ON_EL, textOnEl);

// putting after because the one before exclusively works
// for text and doesn't have a verb before it
// ex: I should see "Press Me Button" on the "Button" inside the "Modal"
Then(REGEX.EL_EXISTS, elExists);
then(REGEX.EL_EXISTS, elExists);

// ex: I should not see the "Buttons" in the "Modal"
// I should not see "Buttons" on the "Page"
// I should not see the "Button"
Then(REGEX.EL_DOES_NOT_EXIST, elDoesNotExist);
then(REGEX.EL_DOES_NOT_EXIST, elDoesNotExist);

// ex: "Username" should be "toli"
Then(REGEX.EL_CONTAINS_TEXT, elHasValue);
then(REGEX.EL_CONTAINS_TEXT, elHasValue);

// ex: "Username's" value should be "toli"
Then(REGEX.EL_VALUE, elHasValue);
then(REGEX.EL_VALUE, elHasValue);

// ex: I should see a "red" background on the "Button"
Then(REGEX.EL_BACKBGROUND, elBackground)
then(REGEX.EL_BACKBGROUND, elBackground)

// ex: I should see a "red" border on the "Button"
Then(REGEX.EL_BORDER, elBorder)
then(REGEX.EL_BORDER, elBorder)
}