@grafana/plugin-e2e 0.17.1 → 0.18.0-canary.757.235cf2d.0
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/README.md +53 -27
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
E2E test Grafana plugins with ease.
|
|
4
4
|
|
|
5
|
+
**Links**
|
|
6
|
+
|
|
7
|
+
- [`@grafana/plugin-e2e` docs](https://grafana.com/developers/plugin-tools/e2e-test-a-plugin/introduction)
|
|
8
|
+
|
|
5
9
|
## Overview
|
|
6
10
|
|
|
7
11
|
`@grafana/plugin-e2e` is designed specifically for Grafana plugin developers. It extends [Playwright test](https://github.com/microsoft/playwright/) capabilities with fixtures, models, and expect matchers, enabling comprehensive end-to-end testing of Grafana plugins across multiple versions of Grafana. This package simplifies the testing process, ensuring your plugin is robust and compatible with various Grafana environments.
|
|
@@ -14,44 +18,66 @@ E2E test Grafana plugins with ease.
|
|
|
14
18
|
- **Version Compatibility:** Ensures that your plugin is tested across multiple versions of Grafana, guaranteeing compatibility and stability.
|
|
15
19
|
- **Integration with Playwright:** Seamlessly integrates with the Playwright testing framework, leveraging its powerful browser automation capabilities.
|
|
16
20
|
|
|
17
|
-
##
|
|
21
|
+
## Get started
|
|
22
|
+
|
|
23
|
+
Checkout our [`Get started`](https://grafana.com/developers/plugin-tools/e2e-test-a-plugin/get-started) guide for detailed instructions on how to install, configure, write tests and run your e2e tests in CI.
|
|
18
24
|
|
|
19
25
|
### Prerequisites
|
|
20
26
|
|
|
27
|
+
- You need to have a Grafana plugin [development environment](https://grafana.com/developers/plugin-tools/get-started/set-up-development-environment)
|
|
21
28
|
- Node.js 18+
|
|
22
|
-
- Basic
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
- Basic Knowledge of Playwright. If you have not worked with Playwright before, we recommend following the [Getting started](https://playwright.dev/docs/intro) section in their documentation
|
|
30
|
+
|
|
31
|
+
#### Install Playwright
|
|
32
|
+
|
|
33
|
+
Please refer to the [Playwright documentation](https://playwright.dev/docs/intro#installing-playwright) for instruction on how to install. `@grafana/plugin-e2e` extends Playwright APIs, so you need to have `Playwright/test` with a minimum version of 0.40.0 installed as a dev dependency in the package.json file of your plugin.
|
|
34
|
+
|
|
35
|
+
#### Configure Playwright
|
|
36
|
+
|
|
37
|
+
Open the Playwright config file that was generated when Playwright was installed and paste the following configuration.
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { dirname } from 'path';
|
|
41
|
+
import { defineConfig, devices } from '@playwright/test';
|
|
42
|
+
const pluginE2eAuth = `${dirname(require.resolve('@grafana/plugin-e2e'))}/auth`;
|
|
43
|
+
|
|
44
|
+
export default defineConfig({
|
|
45
|
+
testDir: './tests', // change this to the directory that was chosen when installing Playwright
|
|
46
|
+
reporter: 'html',
|
|
47
|
+
use: {
|
|
48
|
+
baseURL: 'http://localhost:3000',
|
|
49
|
+
},
|
|
50
|
+
projects: [
|
|
51
|
+
{
|
|
52
|
+
name: 'auth',
|
|
53
|
+
testDir: pluginE2eAuth,
|
|
54
|
+
testMatch: [/.*\.js/],
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'run-tests',
|
|
58
|
+
use: {
|
|
59
|
+
...devices['Desktop Chrome'],
|
|
60
|
+
storageState: 'playwright/.auth/admin.json',
|
|
61
|
+
},
|
|
62
|
+
dependencies: ['auth'],
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
});
|
|
37
66
|
```
|
|
38
67
|
|
|
39
|
-
> Note: @grafana/plugin-e2e uses @playwright/test version 1.40.0 internally, so the version you install in the plugin needs to be the same or higher.
|
|
40
|
-
|
|
41
|
-
## Usage
|
|
42
|
-
|
|
43
68
|
### Writing Tests
|
|
44
69
|
|
|
45
70
|
Here's a basic example of how to write an E2E test using `@grafana/plugin-e2e`:
|
|
46
71
|
|
|
47
|
-
```
|
|
48
|
-
import {
|
|
72
|
+
```ts
|
|
73
|
+
import { test, expect } from '@grafana/plugin-e2e';
|
|
49
74
|
|
|
50
|
-
test('
|
|
51
|
-
await
|
|
52
|
-
|
|
53
|
-
await
|
|
75
|
+
test('data query should return values 1 and 3', async ({ panelEditPage, readProvisionedDataSource }) => {
|
|
76
|
+
const ds = await readProvisionedDataSource({ fileName: 'datasources.yml' });
|
|
77
|
+
await panelEditPage.datasource.set(ds.name);
|
|
78
|
+
await panelEditPage.setVisualization('Table');
|
|
54
79
|
await expect(panelEditPage.refreshPanel()).toBeOK();
|
|
80
|
+
await expect(panelEditPage.panel.data).toContainText(['1', '3']);
|
|
55
81
|
});
|
|
56
82
|
```
|
|
57
83
|
|
|
@@ -63,6 +89,6 @@ To run your tests, use the following command:
|
|
|
63
89
|
npx playwright test
|
|
64
90
|
```
|
|
65
91
|
|
|
66
|
-
|
|
92
|
+
## Contributing
|
|
67
93
|
|
|
68
94
|
We welcome contributions to @grafana/plugin-e2e. If you're interested in contributing, please read our [contributing guidelines](./CONTRIBUTING.md).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grafana/plugin-e2e",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0-canary.757.235cf2d.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"node": ">=18 <=20"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@playwright/test": "^1.
|
|
37
|
+
"@playwright/test": "^1.41.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@playwright/test": "^1.
|
|
40
|
+
"@playwright/test": "^1.41.2",
|
|
41
41
|
"@types/uuid": "^9.0.7",
|
|
42
42
|
"dotenv": "^16.3.1"
|
|
43
43
|
},
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"uuid": "^9.0.1",
|
|
47
47
|
"yaml": "^2.3.4"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "235cf2de505b12058c164366089d67c0d24a7644"
|
|
50
50
|
}
|