2

How to organize the cypress tests based on the environment. I am running my cypress tests again mock server and a real setup both.

While running against mock server i can assume that data is always there and can run the full set, but i can only run a subset of the tests when pointing to a real server.

One option ofcourse is to move them to different folder/spec files, is there any other better way e.g. like barrelling files through index.ts?

Whats the convention in cypress to organize tests based on environment?

Suresh Nagar
  • 1,021
  • 9
  • 20
  • [This repo](https://github.com/optimumqa/cypress-multi-product-template) may help you. It's a template cypress project that lets you easily split tests per product, team, environment, and type. What's left for you to do is just to create the tests in specific folders, and create JSON files in configs to strictly specify which tests to run per which npm command – Darko Riđić May 28 '22 at 23:40

1 Answers1

2

Depending on how you set up your dummy data for tests with the mock server you may might it useful to add @tags to your tests using cypress-grep plugin.

This will allow you to run certain tests with tags and place a @realServer tag for your test only to be ran against your real server.

You may need to alter however you set up the baseUrl for each subset of tests.

jjhelguero
  • 2,281
  • 5
  • 13