Functional Testing with TestCafe
TestCafe is a Node.js end-to-end open source automation tool that is used to test web applications. It can run your tests on any browser without having to download separate drivers for each browser. It is easy to install, configure and get started without any external libraries or plugins required.
TestCafe: Functional tests
Templated sample TestCafe automation framework for PROJECT_NAME, bootstrapped using @amidostacks/scaffolding-cli
.
Running tests locally
Prerequisites
- Ensure that Node.js and npm are installed with the versions specified in
./package.json
file. - Execute the following command to install all dependencies:
Configure your browser:
- Ensure you have at least one browser installed on your operating system e.g. Chrome.
- Include the browser name in the
./.testcaferc.json
file. e.g.:
At the moment, Chrome is set as the default web browser.
To bypass the browser config in the ./.testcaferc.json
config file, simply run passing in the browser arg:
See browsers for more information.
- Configure Environment Variables
TestCafe functional tests are configured to run after successful deployment, so environment variables need to be set.
Export the following environment variables.
Example
- Unix
- Windows
Run Tests
Run tests in a specific browser:
This should launch TestCafe and run the tests in the browsers specified in ./.testcaferc.json
in the headless mode.
Running tests in Docker
In order to be able to run these tests across environments and as part of CI, we need to use Docker to run them.
Build
Run
Optional: Running tests with Lambdatest
Lambdatest is a cloud-based cross browser testing tool that allows to check the web application functionality and other dependencies across various browsers over the internet.
Dependencies
An active Lambdatest Account
Settings
Export Lambdatest Credentials as following:
- Unix
- Windows
Running E2E tests with LambdaTest
Lambdatest will create a tunnel to run the tests and automatically record videos.
The full list of browser configuration available can be found by running the following in the root: