This repository contains testing framework based on Playwright, Typescript and Synpress using Playwright Test as a test runner.
Features:
- Configurable amount of retries and max workers via
.envfile - Basic ESLint and Prettier configuration
- CI setup for tests
- Static code analysis on CI with TypeScript Compiler and ESLint
- HTML report generation
First you'll need to install dependencies:
$ npm installNOTE: If you don't have the correct version of Chromium installed, you can run the following command to install it:
$ npx playwright install chromium
Now, we can optionally set up the environment variables. You can find .env file in the root directory of the project and change the following variables depending on your needs::
# Number of workers to run tests in parallel, default: 1
MAX_WORKERS=1
# Number of retries for each test, default: 0
RETRIES=0
Then we need to build our backend and frontend images, for that follow the steps below:
- Build the frontend and backend images:
$ docker pull evercoinx/faraway:nft-collection-deployer-frontend
$ docker pull evercoinx/faraway:nft-collection-deployer-backend- Get corresponding image IDs
$ docker images- Run containers
$ docker run -p 4000:4000 <Backend Image ID>
$ docker run -p 3000:3000 <Frontend Image ID>To run the tests in the chromium project:
$ npm run testTo generate and open HTML report of the last tests run:
$ npx playwright show-reportYou can also check static code analysis issues with the following commands:
$ npm run lint:fix # Check and fix ESLint issues
$ npm run prettier # Format code with Prettier
$ npm run tsc # Check TypeScript compilation issuesOpen GitHub Action and trigger the job manually.
Tests may fail due to non-isolated environment - the smart contract can be triggered by other users causing new event to appear in the app.
Tests may fail due to insufficient MATIC tokens in the test account. You can top up the account balance by using the faucet: https://www.alchemy.com/faucets/polygon-mumbai
The test account address is:0x5dF162C376950311F2EE4241180611c81c30F517