2.7 KiB
DataLens E2E tests
Prerequisites
Install docker compose plugin if it not already installed
Tests run configuration
Create .env file in root of project. Should be datalens-ui/.env and add:
E2E_DOMAIN=http://localhost:8080
NO_AUTH=false
E2E_USER_LOGIN=admin
E2E_USER_PASSWORD=admin
For additional configuration check list of available ENV variables
Running test
Start containers by docker compose
# It will run containers and UI from current branch.
pnpm test:e2e:docker:up
Run tests via commands:
pnpm test:install:chromium
pnpm test:e2e:opensource
Developing tests in dev mode.
Install Node.js >= v20.18.0 manually or via node version manager.
Change UI port for E2E tests to dev running application at .env file:
E2E_DOMAIN=http://localhost:8080
Start project in dev mode (don't forget to update docker images first):
# It will run only dependent containers without UI.
pnpm test:e2e:docker:up-no-ui
# Start datalens UI in dev mode:
pnpm install --frozen-lockfile
pnpm dev
Run tests via commands:
pnpm test:install:chromium
pnpm test:e2e:opensource
How to add or modify new connection/dataset/chart/dashboard for E2E tests:
- Start project
# Clear existing containers
pnpm test:e2e:docker:down
# Run containers with UI from current branch
pnpm test:e2e:docker:up
- Create necessary test entries in interface
- Run
pnpm test:e2e:us-dump- this command will create new database dump with test entries which you just created
Screenshots tests:
In some cases, you may need to compare the visual representation of widget charts and other elements.
Playwright Test includes the ability to produce and visually compare screenshots using await expect(page).toHaveScreenshot().
Details: https://playwright.dev/docs/test-snapshots
It is convenient to add the @screenshot tag to the name of such tests so that you can immediately update all snapshots if needed.
For example:
datalensTest('Date and time on the Y axis @screenshot', async ({page}) => {
...
});
There are many factors that affect browser rendering on different machines, including hardware and OS configuration. The only reliable way to get identical screenshots is to use identical hosts, or VMs with the same image, or containers. Therefore, to get the correct screenshots (identical to the reference ones), you need to run playwright inside the container:
pnpm test:e2e:docker:snapshots
And later commit the resulting screenshots.