E2E tests (#6717)
Continuation of #6644 Now chromium browser is used in workspaces tests instead of firefox and screenshots after each test are properly saved in one folder when run from IDE and from terminal using `yarn test:e2e` command
This commit is contained in:
@ -1,43 +1,85 @@
|
||||
import { defineConfig, devices } from '@playwright/test';
|
||||
|
||||
import { config } from 'dotenv';
|
||||
import path from 'path';
|
||||
|
||||
config();
|
||||
|
||||
/* === Run your local dev server before starting the tests === */
|
||||
|
||||
/**
|
||||
* See https://playwright.dev/docs/test-configuration.
|
||||
* See https://playwright.dev/docs/trace-viewer to Collect trace when retrying the failed test
|
||||
*/
|
||||
export default defineConfig({
|
||||
testDir: 'e2e',
|
||||
/* Run tests in files in parallel */
|
||||
fullyParallel: true,
|
||||
reporter: 'html',
|
||||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
||||
testDir: '.',
|
||||
outputDir: 'run_results/', // directory for screenshots and videos
|
||||
snapshotPathTemplate: '{testDir}/__screenshots__/{testFilePath}/{arg}{ext}', // just in case, do not delete it
|
||||
fullyParallel: true, // false only for specific tests, overwritten in specific projects or global setups of projects
|
||||
forbidOnly: !!process.env.CI,
|
||||
retries: process.env.CI ? 2 : 0,
|
||||
workers: process.env.CI ? 1 : undefined, // undefined = amount of projects * amount of tests
|
||||
timeout: 30 * 1000, // timeout can be changed
|
||||
use: {
|
||||
/* Base URL to use in actions like `await page.goto('/')`. */
|
||||
baseURL: process.env.FRONTEND_BASE_URL ?? 'http://localhost:3001',
|
||||
baseURL: process.env.CI
|
||||
? process.env.CI_DEFAULT_BASE_URL
|
||||
: (process.env.FRONTEND_BASE_URL ?? 'http://localhost:3001'),
|
||||
trace: 'retain-on-failure', // trace takes EVERYTHING from page source, records every single step, should be used only when normal debugging won't work
|
||||
screenshot: 'on', // either 'on' here or in different method in modules, if 'on' all screenshots are overwritten each time the test is run
|
||||
headless: true, // instead of changing it to false, run 'yarn test:e2e:debug' or 'yarn test:e2e:ui'
|
||||
testIdAttribute: 'data-testid', // taken from Twenty source
|
||||
viewport: { width: 1920, height: 1080 }, // most laptops use this resolution
|
||||
launchOptions: {
|
||||
slowMo: 500, // time in milliseconds between each step, better to use it than explicitly define timeout in tests
|
||||
},
|
||||
},
|
||||
|
||||
/* Configure projects for major browsers */
|
||||
expect: {
|
||||
timeout: 5000,
|
||||
},
|
||||
reporter: [['html', { open: 'never' }]],
|
||||
projects: [
|
||||
{
|
||||
name: 'chromium',
|
||||
use: { ...devices['Desktop Chrome'] },
|
||||
name: 'Login setup',
|
||||
testMatch: /login\.setup\.ts/, // finds all tests matching this regex, in this case only 1 test should be found
|
||||
},
|
||||
{
|
||||
name: 'chromium',
|
||||
use: {
|
||||
...devices['Desktop Chrome'],
|
||||
storageState: path.resolve(__dirname, '.auth', 'user.json'), // takes saved cookies from directory
|
||||
},
|
||||
dependencies: ['Login setup'], // forces to run login setup before running tests from this project - CASE SENSITIVE
|
||||
},
|
||||
|
||||
{
|
||||
name: 'firefox',
|
||||
use: { ...devices['Desktop Firefox'] },
|
||||
use: {
|
||||
...devices['Desktop Firefox'],
|
||||
storageState: path.resolve(__dirname, '.auth', 'user.json'),
|
||||
},
|
||||
dependencies: ['Login setup'],
|
||||
},
|
||||
|
||||
{
|
||||
name: 'webkit',
|
||||
use: { ...devices['Desktop Safari'] },
|
||||
},
|
||||
//{
|
||||
// name: 'webkit',
|
||||
// use: { ...devices['Desktop Safari'] },
|
||||
//},
|
||||
|
||||
{
|
||||
name: 'Google Chrome',
|
||||
use: { ...devices['Desktop Chrome'], channel: 'chrome' },
|
||||
},
|
||||
/* Test against mobile viewports. */
|
||||
// {
|
||||
// name: 'Mobile Chrome',
|
||||
// use: { ...devices['Pixel 5'] },
|
||||
// },
|
||||
// {
|
||||
// name: 'Mobile Safari',
|
||||
// use: { ...devices['iPhone 12'] },
|
||||
// },
|
||||
|
||||
/* Test against branded browsers. */
|
||||
//{
|
||||
// name: 'Microsoft Edge',
|
||||
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
|
||||
//},
|
||||
//{
|
||||
// name: 'Google Chrome',
|
||||
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
|
||||
//},
|
||||
],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user