Environments are named groups of variables that can be applied to test runs in the SnapTest extension. They give you flexibility and scalability when working on teams, with multiple servers, or a large amount of changing test data.

Environments are only used in the SnapTest extension. They do not get generated in the Selenium code.
Environment variables only override variable that have been declared in a test. They won't be available during playback if a test doesn't have a default value set.

A practical example:

Let's say you develop your web application on a local url at: localhost:3000. When you start recording your tests in the extension, the baseUrl will be auto-generated as follows:

SnapTest created the standard baseUrl variable for you. It lives in this test only and can't be shared across other tests... This is an issue if you have many tests and the url changes. Since baseUrl is in each individual test, you have to go back and change them manually.

Does the url change often? You'd be suprised... here are some reasons:

  1. You introduce a staging server, and you want to run the tests against www.staging.myapp.com.
  2. A coworker wants to use a different port or use a host file entry for their development.
  3. Your company buys a new better domain name.

Environments can solve this issue by letting you apply multiple groups of variables across ALL tests. For example, this set of environments change the baseUrl based upon three different servers:

When you run your tests, you can select the environment you'd like to use. The QA team can selected "Staging server", you can select "local dev". When running the test with an environment selected, they will be applied OVER the default test variables.

Group 6Record it…Play it…Generate it…GeneratorsSelector AlgorithmsPrivate modeTest organizationTeamsWorkspacesDedicated supportTest data storageDebugger toolsAdaptable TestsCLI tools and APIWhite-labeled codeVariablesMulti-test playbackManual testsComponents