Playwright: Gate server start up with GRAFANA_URL env var (#108302)

* refactor so server is created unless GRAFANA_URL is provided

* update documentation

* don't swallow errors from the server process
This commit is contained in:
Ashley Harrison
2025-07-18 17:08:47 +01:00
committed by GitHub
parent a7a17c6929
commit 2d1fb94f2d
9 changed files with 32 additions and 19 deletions
+10 -1
View File
@@ -5,6 +5,7 @@ import { PluginOptions } from '@grafana/plugin-e2e';
const testDirRoot = 'e2e-playwright';
const pluginDirRoot = path.join(testDirRoot, 'plugin-e2e');
const DEFAULT_URL = 'http://localhost:3001';
export default defineConfig<PluginOptions>({
fullyParallel: true,
@@ -16,7 +17,7 @@ export default defineConfig<PluginOptions>({
['html'], // pretty
],
use: {
baseURL: `http://${process.env.HOST || 'localhost'}:${process.env.PORT || 3000}`,
baseURL: process.env.GRAFANA_URL ?? DEFAULT_URL,
trace: 'retain-on-failure',
httpCredentials: {
username: 'admin',
@@ -26,6 +27,14 @@ export default defineConfig<PluginOptions>({
permissions: ['clipboard-read', 'clipboard-write'],
provisioningRootDir: path.join(process.cwd(), process.env.PROV_DIR ?? 'conf/provisioning'),
},
...(!process.env.GRAFANA_URL && {
webServer: {
command: 'yarn e2e:plugin:build && ./e2e-playwright/start-server',
url: DEFAULT_URL,
stdout: 'pipe',
stderr: 'pipe',
},
}),
projects: [
// Login to Grafana with admin user and store the cookie on disk for use in other tests
{