@grafana/create-plugin 7.9.2 → 7.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/dist/codemods/migrations/migrations.js +6 -0
- package/dist/codemods/migrations/scripts/013-jest-esmodules.js +65 -0
- package/package.json +1 -1
- package/src/codemods/migrations/migrations.ts +7 -0
- package/src/codemods/migrations/scripts/013-jest-esmodules.test.ts +99 -0
- package/src/codemods/migrations/scripts/013-jest-esmodules.ts +79 -0
- package/templates/common/.config/jest/utils.js +2 -0
- package/templates/common/.config/playwright.config.ts +54 -0
- package/templates/common/.nvmrc +1 -1
- package/templates/common/_package.json +1 -1
- package/templates/common/playwright.config +5 -42
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [7.10.1](https://github.com/grafana/plugin-tools/compare/@grafana/create-plugin@7.10.0...@grafana/create-plugin@7.10.1) (2026-08-27)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **create-plugin:** add @react-hookz/web + @ver0/deep-equal to Jest ESM ignore ([#2847](https://github.com/grafana/plugin-tools/issues/2847)) ([66068ab](https://github.com/grafana/plugin-tools/commit/66068abc145224767470902386949fd8b65f6eaa))
|
|
9
|
+
|
|
10
|
+
## [7.10.0](https://github.com/grafana/plugin-tools/compare/@grafana/create-plugin@7.9.2...@grafana/create-plugin@7.10.0) (2026-08-21)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* **create-plugin:** make Playwright config extendable ([#2807](https://github.com/grafana/plugin-tools/issues/2807)) ([b7dd0fb](https://github.com/grafana/plugin-tools/commit/b7dd0fbf299e6a99bef04a1fc74e4f2c11a17a47))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **templates:** Update dependency @grafana/plugin-e2e to v3.11.0 ([#2825](https://github.com/grafana/plugin-tools/issues/2825)) ([d039033](https://github.com/grafana/plugin-tools/commit/d039033421febaa04a33d7dc2c039d5d761b9723))
|
|
21
|
+
|
|
3
22
|
## [7.9.2](https://github.com/grafana/plugin-tools/compare/@grafana/create-plugin@7.9.1...@grafana/create-plugin@7.9.2) (2026-08-05)
|
|
4
23
|
|
|
5
24
|
|
|
@@ -72,6 +72,12 @@ var defaultMigrations = [
|
|
|
72
72
|
version: "7.8.2",
|
|
73
73
|
description: "Emit a single LICENSE.txt file for all licenses in bundled code.",
|
|
74
74
|
scriptPath: import.meta.resolve("./scripts/012-terser-license-file.js")
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: "013-jest-esmodules",
|
|
78
|
+
version: "7.10.1",
|
|
79
|
+
description: "Support @grafana/ui@13.2.0 in Jest by transforming @react-hookz/web and @ver0/deep-equal ESM dependencies.",
|
|
80
|
+
scriptPath: import.meta.resolve("./scripts/013-jest-esmodules.js")
|
|
75
81
|
}
|
|
76
82
|
// Do not use LEGACY_UPDATE_CUTOFF_VERSION for new migrations. It is only used above to force migrations to run
|
|
77
83
|
// for those written before the switch to updates as migrations.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import * as recast from 'recast';
|
|
3
|
+
import { migrationsDebug } from '../../utils.js';
|
|
4
|
+
import { parseAsTypescript, findVariableDeclaration, printAST } from '../../utils.ast.js';
|
|
5
|
+
|
|
6
|
+
const { builders } = recast.types;
|
|
7
|
+
const JEST_UTILS_PATH = join(".config", "jest", "utils.js");
|
|
8
|
+
const ESM_MODULES_TO_ADD = ["@react-hookz/web", "@ver0/deep-equal"];
|
|
9
|
+
function migrate(context) {
|
|
10
|
+
if (!context.doesFileExist(JEST_UTILS_PATH)) {
|
|
11
|
+
migrationsDebug(`${JEST_UTILS_PATH} not found. Skipping Jest ESM modules migration.`);
|
|
12
|
+
return context;
|
|
13
|
+
}
|
|
14
|
+
const source = context.getFile(JEST_UTILS_PATH);
|
|
15
|
+
if (!source) {
|
|
16
|
+
migrationsDebug(`${JEST_UTILS_PATH} is empty. Skipping Jest ESM modules migration.`);
|
|
17
|
+
return context;
|
|
18
|
+
}
|
|
19
|
+
const parsed = parseAsTypescript(source);
|
|
20
|
+
if (!parsed.success) {
|
|
21
|
+
migrationsDebug(`Failed to parse ${JEST_UTILS_PATH}. Error: ${parsed.error.message}`);
|
|
22
|
+
return context;
|
|
23
|
+
}
|
|
24
|
+
const grafanaESModules = findVariableDeclaration(parsed.ast, "grafanaESModules");
|
|
25
|
+
if (!grafanaESModules) {
|
|
26
|
+
migrationsDebug(`Could not find grafanaESModules variable declaration in ${JEST_UTILS_PATH}`);
|
|
27
|
+
return context;
|
|
28
|
+
}
|
|
29
|
+
if (grafanaESModules.init?.type !== "ArrayExpression") {
|
|
30
|
+
migrationsDebug(`grafanaESModules variable in ${JEST_UTILS_PATH} is not an array.`);
|
|
31
|
+
return context;
|
|
32
|
+
}
|
|
33
|
+
const existingModules = new Set(
|
|
34
|
+
grafanaESModules.init.elements.map(getStringValue).filter((value) => value !== void 0)
|
|
35
|
+
);
|
|
36
|
+
const missingModules = ESM_MODULES_TO_ADD.filter((moduleName) => !existingModules.has(moduleName));
|
|
37
|
+
if (missingModules.length === 0) {
|
|
38
|
+
return context;
|
|
39
|
+
}
|
|
40
|
+
const schemaIndex = grafanaESModules.init.elements.findIndex(
|
|
41
|
+
(element) => getStringValue(element) === "@grafana/schema"
|
|
42
|
+
);
|
|
43
|
+
const insertIndex = schemaIndex === -1 ? grafanaESModules.init.elements.length : schemaIndex + 1;
|
|
44
|
+
grafanaESModules.init.elements.splice(
|
|
45
|
+
insertIndex,
|
|
46
|
+
0,
|
|
47
|
+
...missingModules.map((moduleName) => builders.literal(moduleName))
|
|
48
|
+
);
|
|
49
|
+
context.updateFile(JEST_UTILS_PATH, printAST(parsed.ast));
|
|
50
|
+
return context;
|
|
51
|
+
}
|
|
52
|
+
function getStringValue(element) {
|
|
53
|
+
if (!element) {
|
|
54
|
+
return void 0;
|
|
55
|
+
}
|
|
56
|
+
if (element.type === "Literal" && typeof element.value === "string") {
|
|
57
|
+
return element.value;
|
|
58
|
+
}
|
|
59
|
+
if (element.type === "StringLiteral") {
|
|
60
|
+
return element.value;
|
|
61
|
+
}
|
|
62
|
+
return void 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { migrate as default };
|
package/package.json
CHANGED
|
@@ -84,6 +84,13 @@ export default [
|
|
|
84
84
|
description: 'Emit a single LICENSE.txt file for all licenses in bundled code.',
|
|
85
85
|
scriptPath: import.meta.resolve('./scripts/012-terser-license-file.js'),
|
|
86
86
|
},
|
|
87
|
+
{
|
|
88
|
+
name: '013-jest-esmodules',
|
|
89
|
+
version: '7.10.1',
|
|
90
|
+
description:
|
|
91
|
+
'Support @grafana/ui@13.2.0 in Jest by transforming @react-hookz/web and @ver0/deep-equal ESM dependencies.',
|
|
92
|
+
scriptPath: import.meta.resolve('./scripts/013-jest-esmodules.js'),
|
|
93
|
+
},
|
|
87
94
|
// Do not use LEGACY_UPDATE_CUTOFF_VERSION for new migrations. It is only used above to force migrations to run
|
|
88
95
|
// for those written before the switch to updates as migrations.
|
|
89
96
|
] satisfies Migration[];
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import migrate from './013-jest-esmodules.js';
|
|
3
|
+
import { Context } from '../../context.js';
|
|
4
|
+
|
|
5
|
+
const JEST_UTILS_PATH = '.config/jest/utils.js';
|
|
6
|
+
|
|
7
|
+
const JEST_UTILS = `/*
|
|
8
|
+
* ⚠️⚠️⚠️ THIS FILE WAS SCAFFOLDED BY \`@grafana/create-plugin\`. DO NOT EDIT THIS FILE DIRECTLY. ⚠️⚠️⚠️
|
|
9
|
+
*
|
|
10
|
+
* In order to extend the configuration follow the steps in .config/README.md
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
* This utility function is useful in combination with jest \`transformIgnorePatterns\` config
|
|
15
|
+
* to transform specific packages (e.g.ES modules) in a projects node_modules folder.
|
|
16
|
+
*/
|
|
17
|
+
const nodeModulesToTransform = (moduleNames) => \`node_modules\\/(?!.*(\${moduleNames.join('|')})\\/.*)\`;
|
|
18
|
+
|
|
19
|
+
// Array of known nested grafana package dependencies that only bundle an ESM version
|
|
20
|
+
const grafanaESModules = [
|
|
21
|
+
'.pnpm', // Support using pnpm symlinked packages
|
|
22
|
+
'@grafana/schema',
|
|
23
|
+
'@wojtekmaj/date-utils',
|
|
24
|
+
'd3',
|
|
25
|
+
'uuid',
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
module.exports = {
|
|
29
|
+
nodeModulesToTransform,
|
|
30
|
+
grafanaESModules,
|
|
31
|
+
};
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
describe('013-jest-esmodules', () => {
|
|
35
|
+
it('should add @react-hookz/web and @ver0/deep-equal to grafanaESModules', () => {
|
|
36
|
+
const context = new Context('/virtual');
|
|
37
|
+
context.addFile(JEST_UTILS_PATH, JEST_UTILS);
|
|
38
|
+
|
|
39
|
+
const result = migrate(context);
|
|
40
|
+
const updated = result.getFile(JEST_UTILS_PATH) ?? '';
|
|
41
|
+
|
|
42
|
+
expect(updated).toContain("'@react-hookz/web'");
|
|
43
|
+
expect(updated).toContain("'@ver0/deep-equal'");
|
|
44
|
+
expect(updated.indexOf("'@grafana/schema'")).toBeLessThan(updated.indexOf("'@react-hookz/web'"));
|
|
45
|
+
expect(updated.indexOf("'@ver0/deep-equal'")).toBeLessThan(updated.indexOf("'@wojtekmaj/date-utils'"));
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('should only add missing modules', () => {
|
|
49
|
+
const context = new Context('/virtual');
|
|
50
|
+
context.addFile(
|
|
51
|
+
JEST_UTILS_PATH,
|
|
52
|
+
JEST_UTILS.replace("'@wojtekmaj/date-utils',", "'@react-hookz/web',\n '@wojtekmaj/date-utils',")
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const result = migrate(context);
|
|
56
|
+
const updated = result.getFile(JEST_UTILS_PATH) ?? '';
|
|
57
|
+
|
|
58
|
+
expect(updated.match(/'@react-hookz\/web'/g)).toHaveLength(1);
|
|
59
|
+
expect(updated.match(/'@ver0\/deep-equal'/g)).toHaveLength(1);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should be idempotent', async () => {
|
|
63
|
+
const context = new Context('/virtual');
|
|
64
|
+
context.addFile(JEST_UTILS_PATH, JEST_UTILS);
|
|
65
|
+
|
|
66
|
+
await expect(migrate).toBeIdempotent(context);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('should do nothing when the Jest utils file does not exist', () => {
|
|
70
|
+
const context = new Context('/virtual');
|
|
71
|
+
|
|
72
|
+
const result = migrate(context);
|
|
73
|
+
|
|
74
|
+
expect(result.hasChanges()).toBe(false);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('should do nothing when grafanaESModules is missing', () => {
|
|
78
|
+
const context = new Context('/virtual');
|
|
79
|
+
const customizedUtils = JEST_UTILS.replace('const grafanaESModules = [', 'const customESModules = [');
|
|
80
|
+
context.addFile(JEST_UTILS_PATH, customizedUtils);
|
|
81
|
+
|
|
82
|
+
const result = migrate(context);
|
|
83
|
+
|
|
84
|
+
expect(result.getFile(JEST_UTILS_PATH)).toBe(customizedUtils);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('should do nothing when grafanaESModules is not an array', () => {
|
|
88
|
+
const context = new Context('/virtual');
|
|
89
|
+
const customizedUtils = JEST_UTILS.replace(
|
|
90
|
+
/const grafanaESModules = \[[\s\S]*?\];/,
|
|
91
|
+
"const grafanaESModules = require('./grafana-es-modules');"
|
|
92
|
+
);
|
|
93
|
+
context.addFile(JEST_UTILS_PATH, customizedUtils);
|
|
94
|
+
|
|
95
|
+
const result = migrate(context);
|
|
96
|
+
|
|
97
|
+
expect(result.getFile(JEST_UTILS_PATH)).toBe(customizedUtils);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import * as recast from 'recast';
|
|
3
|
+
import type { Context } from '../../context.js';
|
|
4
|
+
import { migrationsDebug } from '../../utils.js';
|
|
5
|
+
import { findVariableDeclaration, parseAsTypescript, printAST } from '../../utils.ast.js';
|
|
6
|
+
|
|
7
|
+
const { builders } = recast.types;
|
|
8
|
+
|
|
9
|
+
const JEST_UTILS_PATH = join('.config', 'jest', 'utils.js');
|
|
10
|
+
const ESM_MODULES_TO_ADD = ['@react-hookz/web', '@ver0/deep-equal'];
|
|
11
|
+
|
|
12
|
+
export default function migrate(context: Context): Context {
|
|
13
|
+
if (!context.doesFileExist(JEST_UTILS_PATH)) {
|
|
14
|
+
migrationsDebug(`${JEST_UTILS_PATH} not found. Skipping Jest ESM modules migration.`);
|
|
15
|
+
return context;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const source = context.getFile(JEST_UTILS_PATH);
|
|
19
|
+
if (!source) {
|
|
20
|
+
migrationsDebug(`${JEST_UTILS_PATH} is empty. Skipping Jest ESM modules migration.`);
|
|
21
|
+
return context;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const parsed = parseAsTypescript(source);
|
|
25
|
+
if (!parsed.success) {
|
|
26
|
+
migrationsDebug(`Failed to parse ${JEST_UTILS_PATH}. Error: ${parsed.error.message}`);
|
|
27
|
+
return context;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const grafanaESModules = findVariableDeclaration(parsed.ast, 'grafanaESModules');
|
|
31
|
+
if (!grafanaESModules) {
|
|
32
|
+
migrationsDebug(`Could not find grafanaESModules variable declaration in ${JEST_UTILS_PATH}`);
|
|
33
|
+
return context;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (grafanaESModules.init?.type !== 'ArrayExpression') {
|
|
37
|
+
migrationsDebug(`grafanaESModules variable in ${JEST_UTILS_PATH} is not an array.`);
|
|
38
|
+
return context;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const existingModules = new Set(
|
|
42
|
+
grafanaESModules.init.elements.map(getStringValue).filter((value) => value !== undefined)
|
|
43
|
+
);
|
|
44
|
+
const missingModules = ESM_MODULES_TO_ADD.filter((moduleName) => !existingModules.has(moduleName));
|
|
45
|
+
|
|
46
|
+
if (missingModules.length === 0) {
|
|
47
|
+
return context;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const schemaIndex = grafanaESModules.init.elements.findIndex(
|
|
51
|
+
(element) => getStringValue(element) === '@grafana/schema'
|
|
52
|
+
);
|
|
53
|
+
const insertIndex = schemaIndex === -1 ? grafanaESModules.init.elements.length : schemaIndex + 1;
|
|
54
|
+
|
|
55
|
+
grafanaESModules.init.elements.splice(
|
|
56
|
+
insertIndex,
|
|
57
|
+
0,
|
|
58
|
+
...missingModules.map((moduleName) => builders.literal(moduleName))
|
|
59
|
+
);
|
|
60
|
+
context.updateFile(JEST_UTILS_PATH, printAST(parsed.ast));
|
|
61
|
+
|
|
62
|
+
return context;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function getStringValue(element: recast.types.namedTypes.ArrayExpression['elements'][number]): string | undefined {
|
|
66
|
+
if (!element) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (element.type === 'Literal' && typeof element.value === 'string') {
|
|
71
|
+
return element.value;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (element.type === 'StringLiteral') {
|
|
75
|
+
return element.value;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
@@ -14,6 +14,8 @@ const nodeModulesToTransform = (moduleNames) => `node_modules\/(?!.*(${moduleNam
|
|
|
14
14
|
const grafanaESModules = [
|
|
15
15
|
'.pnpm', // Support using pnpm symlinked packages
|
|
16
16
|
'@grafana/schema',
|
|
17
|
+
'@react-hookz/web',
|
|
18
|
+
'@ver0/deep-equal',
|
|
17
19
|
'@wojtekmaj/date-utils',
|
|
18
20
|
'd3',
|
|
19
21
|
'd3-color',
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ⚠️⚠️⚠️ THIS FILE WAS SCAFFOLDED BY `@grafana/create-plugin`. DO NOT EDIT THIS FILE DIRECTLY. ⚠️⚠️⚠️
|
|
3
|
+
*
|
|
4
|
+
* To extend the configuration, follow the steps in
|
|
5
|
+
* https://grafana.com/developers/plugin-tools/how-to-guides/extend-configurations#extend-the-playwright-config
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { PluginOptions } from '@grafana/plugin-e2e';
|
|
9
|
+
import { defineConfig, devices } from '@playwright/test';
|
|
10
|
+
import { dirname } from 'node:path';
|
|
11
|
+
|
|
12
|
+
const pluginE2eAuth = `${dirname(require.resolve('@grafana/plugin-e2e'))}/auth`;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* See https://playwright.dev/docs/test-configuration.
|
|
16
|
+
*/
|
|
17
|
+
export default defineConfig<PluginOptions>({
|
|
18
|
+
testDir: './tests',
|
|
19
|
+
/* Run tests in files in parallel */
|
|
20
|
+
fullyParallel: true,
|
|
21
|
+
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
|
22
|
+
forbidOnly: !!process.env.CI,
|
|
23
|
+
/* Retry on CI only */
|
|
24
|
+
retries: process.env.CI ? 2 : 0,
|
|
25
|
+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
|
26
|
+
reporter: 'html',
|
|
27
|
+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
|
28
|
+
use: {
|
|
29
|
+
/* Base URL to use in actions like `await page.goto('/')`. */
|
|
30
|
+
baseURL: process.env.GRAFANA_URL || 'http://localhost:3000',
|
|
31
|
+
|
|
32
|
+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
|
33
|
+
trace: 'on-first-retry',
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
/* Configure projects for major browsers */
|
|
37
|
+
projects: [
|
|
38
|
+
// 1. Login to Grafana and store the cookie on disk for use in other tests.
|
|
39
|
+
{
|
|
40
|
+
name: 'auth',
|
|
41
|
+
testDir: pluginE2eAuth,
|
|
42
|
+
testMatch: [/.*\.js/],
|
|
43
|
+
},
|
|
44
|
+
// 2. Run tests in Google Chrome. Every test will start authenticated as admin user.
|
|
45
|
+
{
|
|
46
|
+
name: 'chromium',
|
|
47
|
+
use: {
|
|
48
|
+
...devices['Desktop Chrome'],
|
|
49
|
+
storageState: 'playwright/.auth/admin.json',
|
|
50
|
+
},
|
|
51
|
+
dependencies: ['auth'],
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
});
|
package/templates/common/.nvmrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
24
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"license": "Apache-2.0",
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@grafana/eslint-config": "^9.0.0",
|
|
20
|
-
"@grafana/plugin-e2e": "^3.
|
|
20
|
+
"@grafana/plugin-e2e": "^3.11.0",
|
|
21
21
|
"@grafana/sign-plugin": "^3.3.3",
|
|
22
22
|
"@grafana/tsconfig": "^2.2.0",
|
|
23
23
|
"@playwright/test": "^1.62.1",{{#if useExperimentalRspack}}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { PluginOptions } from '@grafana/plugin-e2e';
|
|
2
|
-
import { defineConfig
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
const pluginE2eAuth = `${dirname(require.resolve('@grafana/plugin-e2e'))}/auth`;
|
|
2
|
+
import { defineConfig } from '@playwright/test';
|
|
3
|
+
import baseConfig from './.config/playwright.config';
|
|
6
4
|
|
|
7
5
|
/**
|
|
8
6
|
* Read environment variables from file.
|
|
@@ -13,42 +11,7 @@ const pluginE2eAuth = `${dirname(require.resolve('@grafana/plugin-e2e'))}/auth`;
|
|
|
13
11
|
/**
|
|
14
12
|
* See https://playwright.dev/docs/test-configuration.
|
|
15
13
|
*/
|
|
16
|
-
export default defineConfig<PluginOptions>({
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
|
25
|
-
reporter: 'html',
|
|
26
|
-
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
|
27
|
-
use: {
|
|
28
|
-
/* Base URL to use in actions like `await page.goto('/')`. */
|
|
29
|
-
baseURL: process.env.GRAFANA_URL || 'http://localhost:3000',
|
|
30
|
-
|
|
31
|
-
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
|
32
|
-
trace: 'on-first-retry',
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
/* Configure projects for major browsers */
|
|
36
|
-
projects: [
|
|
37
|
-
// 1. Login to Grafana and store the cookie on disk for use in other tests.
|
|
38
|
-
{
|
|
39
|
-
name: 'auth',
|
|
40
|
-
testDir: pluginE2eAuth,
|
|
41
|
-
testMatch: [/.*\.js/],
|
|
42
|
-
},
|
|
43
|
-
// 2. Run tests in Google Chrome. Every test will start authenticated as admin user.
|
|
44
|
-
{
|
|
45
|
-
name: 'chromium',
|
|
46
|
-
use: {
|
|
47
|
-
...devices['Desktop Chrome'],
|
|
48
|
-
storageState: 'playwright/.auth/admin.json',
|
|
49
|
-
},
|
|
50
|
-
dependencies: ['auth'],
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
|
|
14
|
+
export default defineConfig<PluginOptions>(baseConfig, {
|
|
15
|
+
// Add your own configuration here.
|
|
16
|
+
// See https://grafana.com/developers/plugin-tools/how-to-guides/extend-configurations#extend-the-playwright-config for further info.
|
|
54
17
|
});
|