refactor(playwright): move playwright config and add package.json to prevent esm errors

This commit is contained in:
Jack Westbrook
2025-03-03 09:52:08 +01:00
parent bf68d041fa
commit f75463e170
4 changed files with 18 additions and 16 deletions
+6 -5
View File
@@ -180,11 +180,12 @@ compilation-stats.json
/e2e/extensions
!/e2e/extensions/.keep
/e2e/extensions-suite
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
/playwright/.auth/
test-results/
playwright-report/
blob-report/
playwright/.cache/
playwright/.auth/
# grafana server
/scripts/grafana-server/server.log
+5
View File
@@ -0,0 +1,5 @@
{
"name": "grafana-e2e-playwright-tests",
"description": "This package.json exists to override the 'type': 'module' setting in root package.json",
"type": "commonjs"
}
@@ -1,12 +1,8 @@
import { defineConfig, devices } from '@playwright/test';
import { createRequire } from 'node:module';
import path, { dirname } from 'path';
import { PluginOptions } from '@grafana/plugin-e2e';
const require = createRequire(import.meta.url);
const testDirRoot = 'e2e/plugin-e2e/';
export default defineConfig<PluginOptions>({
fullyParallel: true,
/* Retry on CI only */
@@ -46,7 +42,7 @@ export default defineConfig<PluginOptions>({
// Run all tests in parallel using user with admin role
{
name: 'admin',
testDir: path.join(testDirRoot, '/plugin-e2e-api-tests/as-admin-user'),
testDir: './plugin-e2e-api-tests/as-admin-user',
use: {
...devices['Desktop Chrome'],
storageState: 'playwright/.auth/admin.json',
@@ -56,7 +52,7 @@ export default defineConfig<PluginOptions>({
// Run all tests in parallel using user with viewer role
{
name: 'viewer',
testDir: path.join(testDirRoot, '/plugin-e2e-api-tests/as-viewer-user'),
testDir: './plugin-e2e-api-tests/as-viewer-user',
use: {
...devices['Desktop Chrome'],
storageState: 'playwright/.auth/viewer.json',
@@ -65,7 +61,7 @@ export default defineConfig<PluginOptions>({
},
{
name: 'elasticsearch',
testDir: path.join(testDirRoot, '/elasticsearch'),
testDir: './elasticsearch',
use: {
...devices['Desktop Chrome'],
storageState: 'playwright/.auth/admin.json',
@@ -74,7 +70,7 @@ export default defineConfig<PluginOptions>({
},
{
name: 'mysql',
testDir: path.join(testDirRoot, '/mysql'),
testDir: './mysql',
use: {
...devices['Desktop Chrome'],
storageState: 'playwright/.auth/admin.json',
@@ -83,7 +79,7 @@ export default defineConfig<PluginOptions>({
},
{
name: 'mssql',
testDir: path.join(testDirRoot, '/mssql'),
testDir: './mssql',
use: {
...devices['Desktop Chrome'],
storageState: 'playwright/.auth/admin.json',
@@ -110,7 +106,7 @@ export default defineConfig<PluginOptions>({
},
{
name: 'cloudwatch',
testDir: path.join(testDirRoot, '/cloudwatch'),
testDir: './cloudwatch',
use: {
...devices['Desktop Chrome'],
storageState: 'playwright/.auth/admin.json',
+1 -1
View File
@@ -20,7 +20,7 @@
"e2e:enterprise": "./e2e/start-and-run-suite enterprise",
"e2e:enterprise:dev": "./e2e/start-and-run-suite enterprise dev",
"e2e:enterprise:debug": "./e2e/start-and-run-suite enterprise debug",
"e2e:playwright": "yarn playwright test",
"e2e:playwright": "yarn playwright test -c ./e2e/plugin-e2e/playwright.config.ts",
"e2e:playwright:server": "yarn e2e:plugin:build && ./e2e/plugin-e2e/start-and-run-suite",
"e2e:storybook": "PORT=9001 ./e2e/run-suite storybook true",
"e2e:plugin:build": "nx run-many -t build --projects='@test-plugins/*'",