|
| 1 | +import type { PluginOptions } from '@grafana/plugin-e2e'; |
| 2 | +import { defineConfig, devices } from '@playwright/test'; |
| 3 | +import { dirname } from 'node:path'; |
| 4 | + |
| 5 | +const pluginE2eAuth = `${dirname(require.resolve('@grafana/plugin-e2e'))}/auth`; |
| 6 | + |
| 7 | +/** |
| 8 | + * Read environment variables from file. |
| 9 | + * https://github.com/motdotla/dotenv |
| 10 | + */ |
| 11 | +// require('dotenv').config(); |
| 12 | + |
| 13 | +/** |
| 14 | + * See https://playwright.dev/docs/test-configuration. |
| 15 | + */ |
| 16 | +export default defineConfig<PluginOptions>({ |
| 17 | + testDir: './tests', |
| 18 | + /* Run tests in files in parallel */ |
| 19 | + fullyParallel: true, |
| 20 | + /* Fail the build on CI if you accidentally left test.only in the source code. */ |
| 21 | + forbidOnly: !!process.env.CI, |
| 22 | + /* Retry on CI only */ |
| 23 | + retries: process.env.CI ? 2 : 0, |
| 24 | + /* Opt out of parallel tests on CI. */ |
| 25 | + workers: process.env.CI ? 1 : undefined, |
| 26 | + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ |
| 27 | + reporter: 'html', |
| 28 | + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ |
| 29 | + use: { |
| 30 | + /* Base URL to use in actions like `await page.goto('/')`. */ |
| 31 | + baseURL: 'http://localhost:3000', |
| 32 | + |
| 33 | + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ |
| 34 | + trace: 'on-first-retry', |
| 35 | + }, |
| 36 | + |
| 37 | + /* Configure projects for major browsers */ |
| 38 | + projects: [ |
| 39 | + // 1. Login to Grafana and store the cookie on disk for use in other tests. |
| 40 | + { |
| 41 | + name: 'auth', |
| 42 | + testDir: pluginE2eAuth, |
| 43 | + testMatch: [/.*\.js/], |
| 44 | + }, |
| 45 | + // 2. Run tests in Google Chrome. Every test will start authenticated as admin user. |
| 46 | + { |
| 47 | + name: 'chromium', |
| 48 | + use: { ...devices['Desktop Chrome'], storageState: 'playwright/.auth/admin.json' }, |
| 49 | + dependencies: ['auth'], |
| 50 | + }, |
| 51 | + ], |
| 52 | +}); |
0 commit comments