Skip to content

Instantly share code, notes, and snippets.

@teimurjan
Last active September 28, 2017 05:01
Show Gist options
  • Save teimurjan/b881853d4ec7aeb51464038473c054d5 to your computer and use it in GitHub Desktop.
Save teimurjan/b881853d4ec7aeb51464038473c054d5 to your computer and use it in GitHub Desktop.
FeatureContext.php file, Igor Lee

FeatureContext.php

Feature name to seed name map

Extract as Trait or Factory in a separate file.

Translations map

In order to minify errors after changing texts on frontend we should get translations directly from the frontend's en.json, fr.json files. It can be achieved by reading these files from a FeatureContext.php file method like getTranslationWithCode(locale).

Simplify FeatureContext.php

Make FeatureContext.php contains just features methods like "Before", "BeforeStep" etc. So the steps methods like "I click", "I see" should be added as traits. These traits can be separated to groups: Base("I click", "I see"), Group("I publish", "I assign"), Specific("I see something in specific modal")

Do some "Given" steps programmaticaly

We should use some "Given" steps programmaticaly in order to decrease running time of the tests.

Create spin wrapper

Make a reusable spin wrapper to make code cleaner and tinier

function iFind($xpath, $timeout = 10) {
  return $this->spin(function(FeatureContext $context) use ($xpath) {
      return $context->getSession()->getPage()->find('xpath', $xpath);
  }, $timeout);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment