Testcafe
Testcafe
This document describes how one can start working on a test cafe project from installtion of plugins, cloning the project to run tests and pipeline information.
Clone project in Visual Studio Code
- Create account in github.com
- Get write access to AltinnStudio - https://github.com/Altinn/altinn-studio
- Use windows 10 image with docker.
- Create a folder - C:\Repos
- Open Visual Studio Code
- Ctrl + Shift + P -> Create New Integrated Terminal
- Terminal opens down of Visual Studio Code.
- Navigate to the folder create in step 4 using “cd”
- Clone the project- git clone https://github.com/Altinn/altinn-studio.git
- File -> Add Folder to Workspace -> Select the cloned project: C:\Altinn Studio
- Checkout branch: master
Code for Testcafe tests in altinn.studio
Install Tools
- Open PowerShell -> Verify Node and Npm version
- npm -v (6.9.0)
- node -v (9.5.0)
- Install npm
- npm install -g npm
- Install npm in the Altinn Studio project
- Navigate to the folder - C:\Altinn Studio\altinn-studio\src\test\Testcafe
- Run command – npm install
- Ensure that the environment variables has the path of npm
- C:\Users\UserName\AppData\Roaming\npm
- Navigate to the folder of the testcafe tests in command line (altinn-studio\src\test\Testcafe)
- Run command - npm install testcafe
Run a Test Locally from PowerShell
- Open testRunner.js in Visual Studio Code
- Set the browser as: Chrome
- Speed controls the speed of the execution
- Open a test fixture .js file (e.x., designer_tests -> navigation-tests.js)
- ‘.only’ can be used to run a specific fixture or a test case
- Save the project
- Open PowerShell and navigate to C:\Altinn Studio\altinn-studio\src\test\Testcafe
- Set environment to run the test using: set ENV=dev
- Set password for the test users of Studio using: set “username from config.json”=password
- Run the command – ‘node .\testRunner.js’ to run general tests
- Run the command - ‘node .\WCAGRunner.js’ to run wcag tests