rehael / testcafe-config-example

Configurable test suites – one of many possible approaches…

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TestCafé – Configuration Example

You want to have configurable test scripts, but don't know how to do it with TestCafé?

This small repository provides one of many possible approaches to that.

This repository doesn't deal with TestCafé Configuration, but is focused on making the tests configurable.

Such configuration might be needed when you have a suite of tests you would like to use in different environments, like development, staging, UAT or production.


  1. Define environment variable you will use to drive the choice of configuration with. By default it's env, but you can set your own in config.ts.

  2. Define your configuration in environments.json (or any other file – the file name is in config.ts).

  3. In your test suite, import getConfig from config, call it, and you have access to your data in your tests now.

You can also use --env=xxx parameter - but it will work only when you state browsers and scripts-src in the command line too, before using that unknown by TestCafé parameter.

Setting your CI/CD pipeline variables is not discussed here – roll it on your own.


> set ENV=dev
> yarn test
yarn run v1.22.5
$ testcafe
 Running tests in:
 - Chrome 89.0.4389.128 / Windows 10

 √ Should greet user with Example

 1 passed (1s)
Done in 8.29s.


This work is dual-licensed under the UNLICENSE or MIT license.

Unlicense – just take it and do whatever you need.

If you want indemnity against claims of copyright infringement, and/or you are in a jurisdiction that does not recognize the public domain, and/or you are in a jurisdiction that does not recognize the right of a authors to dedicate their work to the public domain – you may use this work upon the grounds of MIT license, contained in LICENSE.MIT file.

ezoic increase your site revenue


Configurable test suites – one of many possible approaches…

License:The Unlicense


Language:TypeScript 100.0%