@digigov/cli-e2e 1.1.0-rc.21 → 2.0.0-298cfc51
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/.rush/temp/shrinkwrap-deps.json +6 -5
- package/index.js +131 -59
- package/package.json +16 -8
- package/playwright-ct.config.js +111 -0
- package/playwright-ct.config.ts +0 -85
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
"../../tooling/cli-e2e": "../../tooling/cli-e2e:
|
|
3
|
-
"/@playwright/experimental-ct-react@1.41.0(@types/node@
|
|
2
|
+
"../../tooling/cli-e2e": "../../tooling/cli-e2e:7FHeJodyR5vWvAUHQMH4I4T4RwQC6k2u3KHUsQR9JGg=:",
|
|
3
|
+
"/@playwright/experimental-ct-react@1.41.0(@types/node@22.7.5)(lightningcss@1.22.0)(terser@5.33.0)(vite@5.4.11(@types/node@22.7.5)(lightningcss@1.22.0)(sass-embedded@1.81.0)(terser@5.33.0))": "Missing shrinkwrap entry!",
|
|
4
4
|
"/@playwright/test@1.41.0": "Missing shrinkwrap entry!",
|
|
5
|
-
"/autoprefixer@10.4.16(postcss@8.4.
|
|
6
|
-
"/execa@
|
|
5
|
+
"/autoprefixer@10.4.16(postcss@8.4.49)": "Missing shrinkwrap entry!",
|
|
6
|
+
"/execa@8.0.1": "Missing shrinkwrap entry!",
|
|
7
7
|
"/playwright-core@1.41.0": "Missing shrinkwrap entry!",
|
|
8
|
-
"/
|
|
8
|
+
"/publint@0.1.8": "Missing shrinkwrap entry!",
|
|
9
|
+
"/tailwindcss@3.4.13(ts-node@10.9.2(@types/node@22.7.5)(typescript@5.6.2))": "Missing shrinkwrap entry!"
|
|
9
10
|
}
|
package/index.js
CHANGED
|
@@ -1,71 +1,143 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const {spawn} = require('child_process');
|
|
6
|
-
|
|
7
|
-
module.exports = class E2E extends DigigovCommand {
|
|
8
|
-
static description = 'e2e digigov projects';
|
|
9
|
-
static id = 'e2e';
|
|
10
|
-
dirname = __dirname;
|
|
11
|
-
static examples = [
|
|
12
|
-
`$ digigov e2e`,
|
|
13
|
-
];
|
|
14
|
-
static strict = false;
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { logger, resolveProject, DigigovCommand } from "@digigov/cli/lib";
|
|
4
|
+
import { execa } from "execa";
|
|
15
5
|
|
|
16
|
-
|
|
17
|
-
async run() {
|
|
18
|
-
let playwrightConfigFile = '';
|
|
19
|
-
const {argv} = this.parse(E2E);
|
|
20
|
-
const project = resolveProject();
|
|
6
|
+
const command = new DigigovCommand("e2e", import.meta.url);
|
|
21
7
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
8
|
+
command
|
|
9
|
+
.argument("[args...]", "arguments to pass to playwright")
|
|
10
|
+
.helpOption(false)
|
|
11
|
+
.allowUnknownOption()
|
|
12
|
+
.action(runE2e);
|
|
25
13
|
|
|
26
|
-
|
|
27
|
-
playwrightConfigFile = 'playwright-ct.config.ts';
|
|
28
|
-
}
|
|
14
|
+
export default command;
|
|
29
15
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Run Playwright tests
|
|
18
|
+
* @param {string[]} args
|
|
19
|
+
* @param {Record<string, unknown>} options
|
|
20
|
+
* @param {DigigovCommand} ctx
|
|
21
|
+
*/
|
|
22
|
+
async function runE2e(args, options, ctx) {
|
|
23
|
+
/** @type {string | null} */
|
|
24
|
+
const project = resolveProject();
|
|
25
|
+
let playwrightConfig = getPlaywrightConfig(project.root);
|
|
33
26
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
'cd /home/pwuser && npx -y playwright@1.41.0 run-server --port 54380 --host 0.0.0.0 '
|
|
40
|
-
];
|
|
41
|
-
const proc = spawn('docker', dockerCommand, {stdio: ['inherit', 'pipe', 'ignore']});
|
|
42
|
-
await new Promise((resolve, reject) => {
|
|
43
|
-
proc.stdout.on('data', (data) => {
|
|
44
|
-
const output = data.toString();
|
|
45
|
-
if(output.includes('Listening on')) {
|
|
46
|
-
resolve();
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
proc.on('error', (error) => {
|
|
50
|
-
console.error('Failed to start the Playwright server:', error);
|
|
51
|
-
reject(error);
|
|
52
|
-
});
|
|
53
|
-
});
|
|
27
|
+
if (!playwrightConfig) {
|
|
28
|
+
throw new Error("No playwright config found in project folder");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
logger.debug(`Found playwright config file: ${playwrightConfig}`);
|
|
54
32
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
33
|
+
const dockerCommand = [
|
|
34
|
+
"run",
|
|
35
|
+
"--net=host",
|
|
36
|
+
"--rm",
|
|
37
|
+
"--init",
|
|
38
|
+
"-it",
|
|
39
|
+
"mcr.microsoft.com/playwright:v1.41.0-jammy",
|
|
40
|
+
"/bin/sh",
|
|
41
|
+
"-c",
|
|
42
|
+
"cd /home/pwuser && npx -y playwright@1.41.0 run-server --port 54380 --host 0.0.0.0 ",
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
logger.debug(
|
|
46
|
+
"Starting docker container with command: ",
|
|
47
|
+
"docker",
|
|
48
|
+
dockerCommand.join(" "),
|
|
49
|
+
);
|
|
50
|
+
const docker = execa("docker", dockerCommand, {
|
|
51
|
+
stdin: "inherit",
|
|
52
|
+
stdout: "pipe",
|
|
53
|
+
stderr: "pipe",
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
logger.debug("Docker container pid:", docker.pid);
|
|
57
|
+
|
|
58
|
+
await new Promise((resolve, reject) => {
|
|
59
|
+
docker.on("message", (message) => {
|
|
60
|
+
logger.debug("Docker message:", message);
|
|
61
|
+
});
|
|
62
|
+
docker.stdout.on("data", (data) => {
|
|
63
|
+
const output = data.toString();
|
|
64
|
+
logger.debug("Docker stdout:", output);
|
|
65
|
+
if (output.includes("Listening on")) {
|
|
66
|
+
resolve();
|
|
60
67
|
}
|
|
61
68
|
});
|
|
69
|
+
docker.stderr.on("data", (data) => {
|
|
70
|
+
const errorOutput = data.toString();
|
|
71
|
+
logger.error("Docker stderr:", errorOutput);
|
|
72
|
+
});
|
|
73
|
+
docker.on("error", (error) => {
|
|
74
|
+
logger.error("Failed to start the docker container:", error);
|
|
75
|
+
reject(error);
|
|
76
|
+
});
|
|
77
|
+
docker.on("close", (code) => {
|
|
78
|
+
if (code !== 0) {
|
|
79
|
+
const msg = `Docker process exited with code ${code}`;
|
|
80
|
+
logger.error(msg);
|
|
81
|
+
reject(new Error(msg));
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// if (!options["debug"]) console.clear();
|
|
87
|
+
|
|
88
|
+
logger.debug("Starting Playwright tests");
|
|
89
|
+
try {
|
|
90
|
+
const playwright = ctx.exec(
|
|
91
|
+
`playwright`,
|
|
92
|
+
[`test`, `-c`, playwrightConfig, ...args],
|
|
93
|
+
{
|
|
94
|
+
stdio: ["inherit", "inherit", "inherit"],
|
|
95
|
+
env: {
|
|
96
|
+
PW_TEST_CONNECT_WS_ENDPOINT: "ws://127.0.0.1:54380/",
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
process.on("SIGINT", () => {
|
|
102
|
+
logger.debug("Received SIGINT, terminating processes...");
|
|
103
|
+
docker.kill("SIGINT");
|
|
104
|
+
process.exit(0);
|
|
105
|
+
});
|
|
62
106
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
107
|
+
process.on("SIGTERM", () => {
|
|
108
|
+
logger.debug("Received SIGTERM, terminating processes...");
|
|
109
|
+
docker.kill("SIGTERM");
|
|
110
|
+
process.exit(0);
|
|
66
111
|
});
|
|
67
|
-
|
|
68
|
-
|
|
112
|
+
docker.on("exit", () => {
|
|
113
|
+
logger.debug("Docker process exited");
|
|
114
|
+
playwright.kill("SIGINT");
|
|
115
|
+
process.exit(1);
|
|
69
116
|
});
|
|
117
|
+
playwright.on("exit", () => process.exit(0));
|
|
118
|
+
} catch (error) {
|
|
119
|
+
logger.error("Playwright process failed:", error);
|
|
120
|
+
docker.kill("SIGINT");
|
|
121
|
+
process.exit(1);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const EXTENSIONS = [".mts", ".mjs", ".ts", ".js"];
|
|
126
|
+
const FILE_NAMES = ["playwright.config", "playwright-ct.config"];
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Get the Playwright config file
|
|
130
|
+
* @param {string} projectRoot
|
|
131
|
+
* @returns {string | null} The path to the playwright config file
|
|
132
|
+
*/
|
|
133
|
+
function getPlaywrightConfig(projectRoot) {
|
|
134
|
+
for (const ext of EXTENSIONS) {
|
|
135
|
+
for (const name of FILE_NAMES) {
|
|
136
|
+
const playwrightConfig = path.join(projectRoot, `${name}${ext}`);
|
|
137
|
+
if (fs.existsSync(playwrightConfig)) {
|
|
138
|
+
return playwrightConfig;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
70
141
|
}
|
|
71
|
-
|
|
142
|
+
return null;
|
|
143
|
+
}
|
package/package.json
CHANGED
|
@@ -1,22 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digigov/cli-e2e",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "2.0.0-298cfc51",
|
|
4
|
+
"description": "E2E test plugin for Digigov CLI",
|
|
5
|
+
"author": "GRNET Devs <devs@lists.grnet.gr>",
|
|
6
|
+
"license": "BSD-2-Clause",
|
|
5
7
|
"main": "index.js",
|
|
8
|
+
"type": "module",
|
|
6
9
|
"dependencies": {
|
|
7
|
-
"execa": "
|
|
10
|
+
"execa": "8.0.1"
|
|
11
|
+
},
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"publint": "0.1.8"
|
|
8
14
|
},
|
|
9
15
|
"peerDependencies": {
|
|
10
|
-
"@digigov/cli": "
|
|
16
|
+
"@digigov/cli": "2.0.0-298cfc51",
|
|
11
17
|
"@playwright/experimental-ct-react": "1.41.0",
|
|
12
18
|
"@playwright/test": "1.41.0",
|
|
13
19
|
"playwright-core": "1.41.0",
|
|
14
20
|
"autoprefixer": "10.4.16",
|
|
15
|
-
"tailwindcss": "3.
|
|
21
|
+
"tailwindcss": "3.4.13"
|
|
22
|
+
},
|
|
23
|
+
"exports": {
|
|
24
|
+
".": "./index.js",
|
|
25
|
+
"./playwright-ct.config": "./playwright-ct.config.js"
|
|
16
26
|
},
|
|
17
|
-
"author": "",
|
|
18
|
-
"license": "ISC",
|
|
19
27
|
"scripts": {
|
|
20
|
-
"
|
|
28
|
+
"publint": "publint"
|
|
21
29
|
}
|
|
22
30
|
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { devices, defineConfig } from "@playwright/experimental-ct-react";
|
|
2
|
+
import { resolveProject } from "@digigov/cli/lib";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import assert from "node:assert";
|
|
6
|
+
import { createRequire } from "module";
|
|
7
|
+
|
|
8
|
+
const require = createRequire(import.meta.url);
|
|
9
|
+
|
|
10
|
+
const alias = {};
|
|
11
|
+
const IS_DOCKER = process.env["IS_DOCKER"] ?? false;
|
|
12
|
+
const WORKERS = parseInt(process.env["TEST_E2E_WORKERS"] ?? "4");
|
|
13
|
+
assert(
|
|
14
|
+
WORKERS > 0,
|
|
15
|
+
"TEST_E2E_WORKERS should be a positive integer, was '" +
|
|
16
|
+
process.env["TEST_E2E_WORKERS"] +
|
|
17
|
+
"'",
|
|
18
|
+
);
|
|
19
|
+
const project = resolveProject();
|
|
20
|
+
const postcss = fs.existsSync(path.join(project.root, "tailwind.config.js"))
|
|
21
|
+
? {
|
|
22
|
+
plugins: [
|
|
23
|
+
require("tailwindcss")(
|
|
24
|
+
require(path.join(project.root, "tailwind.config.js")),
|
|
25
|
+
),
|
|
26
|
+
require("autoprefixer"),
|
|
27
|
+
],
|
|
28
|
+
}
|
|
29
|
+
: {};
|
|
30
|
+
const EXCLUDE_ALIAS = ["@digigov/css"];
|
|
31
|
+
if (project.src) {
|
|
32
|
+
alias[project.name] = path.join(project.root, "src");
|
|
33
|
+
} else {
|
|
34
|
+
alias[project.name] = project.root;
|
|
35
|
+
}
|
|
36
|
+
Object.keys(project.dependencies).forEach((dep) => {
|
|
37
|
+
if (dep.match(/^(@digigov|@uides)/) && !EXCLUDE_ALIAS.includes(dep)) {
|
|
38
|
+
if (
|
|
39
|
+
fs.existsSync(`${path.join(project.root, "node_modules", dep, "src")}`)
|
|
40
|
+
) {
|
|
41
|
+
alias[dep] = path.join(project.root, "node_modules", dep, "src");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
/**
|
|
46
|
+
* See https://playwright.dev/docs/test-configuration.
|
|
47
|
+
*
|
|
48
|
+
* @type {import('@playwright/experimental-ct-react').PlaywrightTestConfig}
|
|
49
|
+
*/
|
|
50
|
+
const config = defineConfig({
|
|
51
|
+
testDir: "./",
|
|
52
|
+
snapshotPathTemplate:
|
|
53
|
+
"{testFileDir}/__screenshots__/{projectName}-{arg}{ext}",
|
|
54
|
+
testMatch: "**/*.test.tsx",
|
|
55
|
+
testIgnore: [
|
|
56
|
+
"*src/govgr",
|
|
57
|
+
"*dist/**/*.test.*",
|
|
58
|
+
"**/*.spec.*",
|
|
59
|
+
"__snapshots__",
|
|
60
|
+
"__stories__",
|
|
61
|
+
"__mocks__",
|
|
62
|
+
"__tests__",
|
|
63
|
+
"__fixtures__",
|
|
64
|
+
],
|
|
65
|
+
/* The base directory, relative to the config file, for snapshot files created with toMatchSnapshot and toHaveScreenshot. */
|
|
66
|
+
snapshotDir: "./__snapshots__",
|
|
67
|
+
/* Maximum time one test can run for. */
|
|
68
|
+
timeout: 10 * 1000,
|
|
69
|
+
/* Run tests in files in parallel */
|
|
70
|
+
fullyParallel: true,
|
|
71
|
+
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
|
72
|
+
forbidOnly: !!process.env.CI,
|
|
73
|
+
/* Retry on CI only */
|
|
74
|
+
retries: process.env.CI ? 3 : 0,
|
|
75
|
+
/* Number of worker threads, ie tests that run in parallel. */
|
|
76
|
+
workers: 1,
|
|
77
|
+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
|
78
|
+
reporter: [["list"], ["html", { open: "never" }]],
|
|
79
|
+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
|
80
|
+
use: {
|
|
81
|
+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
|
82
|
+
trace: "on-first-retry",
|
|
83
|
+
|
|
84
|
+
/* Port to use for Playwright component endpoint. */
|
|
85
|
+
ctPort: 3100,
|
|
86
|
+
ctViteConfig: {
|
|
87
|
+
resolve: {
|
|
88
|
+
alias,
|
|
89
|
+
},
|
|
90
|
+
css: {
|
|
91
|
+
postcss,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
/* Configure projects for major browsers */
|
|
96
|
+
projects: [
|
|
97
|
+
{
|
|
98
|
+
name: "desktop",
|
|
99
|
+
use: {
|
|
100
|
+
...devices["Desktop Chrome"],
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: "mobile",
|
|
105
|
+
use: {
|
|
106
|
+
...devices["Galaxy S8"],
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
});
|
|
111
|
+
export default config;
|
package/playwright-ct.config.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import type { PlaywrightTestConfig } from '@playwright/experimental-ct-react';
|
|
2
|
-
import { devices, defineConfig } from '@playwright/experimental-ct-react';
|
|
3
|
-
import { resolveProject } from '@digigov/cli/resolveProject';
|
|
4
|
-
import fs from 'fs';
|
|
5
|
-
import path from 'path';
|
|
6
|
-
import assert from 'node:assert';
|
|
7
|
-
const alias = {}
|
|
8
|
-
const IS_DOCKER = process.env['IS_DOCKER'] ?? false;
|
|
9
|
-
const WORKERS = parseInt(process.env['TEST_E2E_WORKERS'] ?? '4');
|
|
10
|
-
assert(WORKERS > 0, "TEST_E2E_WORKERS should be a positive integer, was '" + process.env['TEST_E2E_WORKERS'] +"'");
|
|
11
|
-
const project = resolveProject();
|
|
12
|
-
const postcss = fs.existsSync(path.join(project.root, 'tailwind.config.js')) ? {
|
|
13
|
-
plugins: [
|
|
14
|
-
require('tailwindcss')(require(path.join(project.root, 'tailwind.config.js'))),
|
|
15
|
-
require('autoprefixer'),
|
|
16
|
-
]
|
|
17
|
-
} : {}
|
|
18
|
-
const EXCLUDE_ALIAS = ['@digigov/css']
|
|
19
|
-
if(project.src){
|
|
20
|
-
alias[project.name] = path.join(project.root,'src')
|
|
21
|
-
}else{
|
|
22
|
-
alias[project.name] = project.root
|
|
23
|
-
}
|
|
24
|
-
Object.keys(project.dependencies).forEach((dep) => {
|
|
25
|
-
if (dep.match(/^(@digigov|@uides)/) && !EXCLUDE_ALIAS.includes(dep)) {
|
|
26
|
-
if (fs.existsSync(`${path.join(project.root, 'node_modules', dep, 'src')}`)) {
|
|
27
|
-
alias[dep] = path.join(project.root, 'node_modules', dep, 'src')
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
})
|
|
31
|
-
/**
|
|
32
|
-
* See https://playwright.dev/docs/test-configuration.
|
|
33
|
-
*/
|
|
34
|
-
const config: PlaywrightTestConfig = defineConfig({
|
|
35
|
-
testDir: './',
|
|
36
|
-
snapshotPathTemplate: '{testFileDir}/__screenshots__/{projectName}-{arg}{ext}',
|
|
37
|
-
testMatch: '**/*.test.tsx',
|
|
38
|
-
testIgnore: ['*src/govgr', '*dist/**/*.test.*','**/*.spec.*', '__snapshots__', '__stories__', '__mocks__', '__tests__', '__fixtures__'],
|
|
39
|
-
/* The base directory, relative to the config file, for snapshot files created with toMatchSnapshot and toHaveScreenshot. */
|
|
40
|
-
snapshotDir: './__snapshots__',
|
|
41
|
-
/* Maximum time one test can run for. */
|
|
42
|
-
timeout: 10 * 1000,
|
|
43
|
-
/* Run tests in files in parallel */
|
|
44
|
-
fullyParallel: true,
|
|
45
|
-
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
|
46
|
-
forbidOnly: !!process.env.CI,
|
|
47
|
-
/* Retry on CI only */
|
|
48
|
-
retries: process.env.CI ? 3 : 0,
|
|
49
|
-
/* Number of worker threads, ie tests that run in parallel. */
|
|
50
|
-
workers: 1,
|
|
51
|
-
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
|
52
|
-
reporter: [['list'], ['html', { open: 'never' }]],
|
|
53
|
-
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
|
54
|
-
use: {
|
|
55
|
-
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
|
56
|
-
trace: 'on-first-retry',
|
|
57
|
-
|
|
58
|
-
/* Port to use for Playwright component endpoint. */
|
|
59
|
-
ctPort: 3100,
|
|
60
|
-
ctViteConfig: {
|
|
61
|
-
resolve: {
|
|
62
|
-
alias
|
|
63
|
-
},
|
|
64
|
-
css: {
|
|
65
|
-
postcss
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
/* Configure projects for major browsers */
|
|
70
|
-
projects: [
|
|
71
|
-
{
|
|
72
|
-
name: 'desktop',
|
|
73
|
-
use: {
|
|
74
|
-
...devices['Desktop Chrome'],
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
name: 'mobile',
|
|
79
|
-
use: {
|
|
80
|
-
...devices['Galaxy S8'],
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
],
|
|
84
|
-
});
|
|
85
|
-
export default config;
|