grafana/playwright.config.ts
Erik Sundell 2a7785c262
CI: Allow failed Playwright tests to fail entire build (#84244)
* bump plugin-e2e and fix failing test

* do not ignore failures

* generate trace on every test

* force test to fail for debugging purposes

* fix broken test

* regenerate drone file
2024-03-12 13:48:32 +01:00

66 lines
2.0 KiB
TypeScript

import { defineConfig, devices } from '@playwright/test';
import path, { dirname } from 'path';
import { PluginOptions } from '@grafana/plugin-e2e';
const testDirRoot = 'e2e/plugin-e2e/plugin-e2e-api-tests/';
export default defineConfig<PluginOptions>({
fullyParallel: true,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
reporter: 'html',
use: {
baseURL: `http://${process.env.HOST || 'localhost'}:${process.env.PORT || 3000}`,
trace: 'retain-on-failure',
httpCredentials: {
username: 'admin',
password: 'admin',
},
provisioningRootDir: path.join(process.cwd(), process.env.PROV_DIR ?? 'conf/provisioning'),
},
projects: [
// Login to Grafana with admin user and store the cookie on disk for use in other tests
{
name: 'authenticate',
testDir: `${dirname(require.resolve('@grafana/plugin-e2e'))}/auth`,
testMatch: [/.*\.js/],
},
// Login to Grafana with new user with viewer role and store the cookie on disk for use in other tests
{
name: 'createUserAndAuthenticate',
testDir: `${dirname(require.resolve('@grafana/plugin-e2e'))}/auth`,
testMatch: [/.*\.js/],
use: {
user: {
user: 'viewer',
password: 'password',
role: 'Viewer',
},
},
},
// Run all tests in parallel using user with admin role
{
name: 'admin',
testDir: path.join(testDirRoot, '/as-admin-user'),
use: {
...devices['Desktop Chrome'],
storageState: 'playwright/.auth/admin.json',
},
dependencies: ['authenticate'],
},
// Run all tests in parallel using user with viewer role
{
name: 'viewer',
testDir: path.join(testDirRoot, '/as-viewer-user'),
use: {
...devices['Desktop Chrome'],
storageState: 'playwright/.auth/viewer.json',
},
dependencies: ['createUserAndAuthenticate'],
},
],
});