- You should have Node.js installed on your machine. Download LTS (long-term support) release compatible with your OS.
- You should have an IDE (eg. VS Code) and its extension for Playwright for convenience of running and debugging tests.
- You should have Git installed. Choose a proper instruction for your OS. You can use VSCode as a Git client or install another for convenience (eg. SourceTree, GitExtensions, etc.)
- Generate an SSH key pair and add it to your GitLab profile, see how to generate SSH
Now you're ready to clone the repository 🎉
- Go to a folder on your machine that you will use as your working directory.
- Clone repository to your working directory using this guide how to clone Git repo
- Open a terminal, go to your working directory and run
npm install
. This will install the dependencies frompackage.json
file. - Possible you may need install browsers (f.ex.
npx playwright install chromium
)
In order to run tests across different environments you need to create .env file.
You can use next command to create .env : cp .env.example .env
Or you can create it by hand and paste environment variables that are described in this PR [Environment variables] (https://git.epam.com/epm-lsop/ketcher-autotests/-/merge_requests/10)
Starts running all the tests
Starts testing with debugging enabled
where <any_string>
can be a part of filename, for example. Example: npm run test -- canvas
. It will run tests in ketcher-canvas.spec.ts
.
Updates screenshots. Run only if you are sure, that functionality has been changed and screenshot is no longer valid.
Starts a playwright codegen tool to simplify the script creation. Check the codegen documentation
Folders are named the same as structure in Jira
Check for additional information on Playwright scripts here https://playwright.dev/docs/running-tests#command-line
You can add DeploySentinel Recorder https://www.deploysentinel.com/docs/recorder extension for Google Chrome. It allows to record user interactions in browser and generate playwright code.
To search some bond / atom testers can use next methods:
For atoms:
getAtomByIndex - get atom by attributes and index getTopAtomByAttributes - get top atom by attributes getRightAtomByAttributes - get right atom by attributes getBottomAtomByAttributes - get bottom atom by attributes getLeftAtomByAttributes - get left atom by attributes getFirstAtomCoordinatesByAttributes - get one atom by attributes
For bonds:
getBondByIndex - get bond by attributes and index getTopBondByAttributes - get top bond by attributes getRightBondByAttributes - get right bond by attributes getBottomBondByAttributes - get bottom bond by attributes getLeftBondByAttributes - get left bond by attributes getFirstBondCoordinatesByAttributes - get one bond by attributes
To select tools with nested / sub levels use:
selectNestedTool - select specific tool that has sub / nested levels.
- Docker runs automatically in the pipeline after pushing changes to the repository.
- When you want to run tests in Docker on your computer, Docker should be run
- Docker allows creating snapshots independent of the operating system
- Docker Desktop
- How to install for Mac OS: https://docs.docker.com/desktop/install/mac-install/
- How to install for Windows: https://docs.docker.com/desktop/install/windows-install/
- How to install for Linux: https://docs.docker.com/desktop/install/linux-install/
- Build Docker:
- Directory "ketcher-autotests":
npm run docker:build
- Directory "ketcher-autotests":
- Set environment:
In the directory "ketcher-autotests" set .env variable
- DOCKER=true
- KETCHER_URL
- Rc: KETCHER_URL=link_to_rc
- Local frontend: KETCHER_URL=http://localhost:4002
- OPTIONAL: IGNORE_UNSTABLE_TESTS=true (if you want to ignore unstable tests)
- OPTIONAL: ENABLE_POLYMER_EDITOR=true (If you want to run tests for Macromolecule Editor)
- OPTIONAL: NUM_WORKERS=8 (default=num cpus, if you want to define custom number of workers)
**OPTIONAL: Test Polymer Editor **:
If you want to run tests from Macromolecule Editor, add ENABLE_POLYMER_EDITOR=true
in scripts:
- Root package.json: "build:example": "ENABLE_POLYMER_EDITOR=true npm run build -w example";
Also make sure, that test is not skipped! Check if test starts with
test.skip('We test something', async ({ page }) => {
Remove "skip" before running.
-
Run app in browser: from root directory "ketcher":
-
npm ci
-
npm run build
-
npm run serve
-
Run tests using docker:
cd ketcher-autotests
npm run docker:build
npm run docker:test
- Write a test and make sure, that it works on your local machine.
- Run command npm run docker:test
- Docker will generate a snapshot for Linux. Make
commit, push
your test and snapshot for Linux in the repository.
(snapshot for mac OS and windows will be ignored and won't be in GitHub)
Run this command in the directory "ketcher-autotests"
npm run docker:test
run all testsnpm run docker:test file_name
run tests in a specific filenpm run docker:test file_name:N
run specific test in a file (N - line on which test starts)npm run report
show reportnpm run docker:update
update all snapshotsnpm run docker:update file_name:N
update specific test in a file (N - line on which test starts)npm run docker:update:test -- "test_title"
update only 1 snapshot with test_title
If no NPM installed (only docker) to build ketcher the same compiler as on CI platforms, use the following command
Build Ketcher
docker-compose build ketcher
docker-compose run --rm --user $(id -u) ketcher bash /app/test_build.sh
Prepare tests
docker-compose build autotests
docker-compose run --rm --user $(id -u) autotests bash /app/test_prepare.sh
Run tests
docker-compose run --rm --user $(id -u) autotests bash /app/test_run.sh
Run pattern
docker-compose run --rm --user $(id -u) autotests bash /app/test_run.sh -g "Cut the reaction"
Run update
docker-compose run --rm --user $(id -u) autotests bash /app/test_run.sh -g "Cut the reaction" --update-snapshots
The "file name too long" error in Git is related to the maximum length of file names in the operating system. In most cases, this happens on Windows systems, where the maximum path length to a file is 260 characters.
One way to work around this limitation in Git is to use the command git config --system core.longpaths true. This command allows Git to work with long file names on Windows that exceed the maximum path length.
If you do not have administrator rights, you can try to modify the Git configuration for the current user using the command git config --global core.longpaths true. This command will modify the Git settings only for your user account, and administrator rights are not required to execute it.