@lowdefy/block-dev-e2e 0.0.0-experimental-20260929135001 → 0.0.0-experimental-20260930181833

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.
@@ -14,29 +14,36 @@
14
14
  limitations under the License.
15
15
  */ import path from 'path';
16
16
  import { defineConfig, devices } from '@playwright/test';
17
- function createPlaywrightConfig({ packageDir, port: defaultPort = 3001 }) {
17
+ // A package's block e2e suite builds and serves `e2e/app`. A package can also run a second
18
+ // suite against an app of its own (`appDir`, `name`, `testMatch`), with services such as a
19
+ // database or mock APIs started before the app (`services`, Playwright webServer entries) and
20
+ // environment variables for the app server (`env`).
21
+ function createPlaywrightConfig({ packageDir, port: defaultPort = 3001, appDir: appDirOption, name, testMatch = [
22
+ 'src/**/tests/*.e2e.spec.js',
23
+ 'e2e/tests/*.e2e.spec.js'
24
+ ], services = [], env, fullyParallel = true, workers }) {
18
25
  // Worktrees share the machine, so a fixed port could reach another checkout's server.
19
26
  // LOWDEFY_E2E_PORT moves the run, and an existing server is only reused on request.
20
27
  const port = Number(process.env.LOWDEFY_E2E_PORT ?? defaultPort);
21
28
  const e2eDir = path.join(packageDir, 'e2e');
22
- const appDir = path.join(e2eDir, 'app');
29
+ const appDir = appDirOption ?? path.join(e2eDir, 'app');
30
+ const suiteName = name ?? path.basename(packageDir);
23
31
  // Calculate paths relative to monorepo root
24
32
  // packageDir is like: /path/to/lowdefy/packages/plugins/blocks/blocks-basic
25
33
  const monorepoRoot = path.resolve(packageDir, '../../../../');
26
34
  const cliPath = path.join(monorepoRoot, 'packages/cli/dist/index.js');
27
35
  const prepareServerPath = path.join(monorepoRoot, 'scripts/prepare-e2e-server.mjs');
28
- // Each package builds into its own untracked copy of the server, so a run leaves the
29
- // worktree clean and different packages can run at the same time.
30
- const serverDir = path.join(monorepoRoot, '_server/e2e', path.basename(packageDir));
36
+ // Each suite builds into its own untracked copy of the server, so a run leaves the
37
+ // worktree clean and different suites can run at the same time.
38
+ const serverDir = path.join(monorepoRoot, '_server/e2e', suiteName);
39
+ const reuseExistingServer = process.env.LOWDEFY_E2E_REUSE_SERVER === 'true';
31
40
  return defineConfig({
32
41
  testDir: packageDir,
33
- testMatch: [
34
- 'src/**/tests/*.e2e.spec.js',
35
- 'e2e/tests/*.e2e.spec.js'
36
- ],
37
- fullyParallel: true,
42
+ testMatch,
43
+ fullyParallel,
44
+ workers,
38
45
  reporter: 'list',
39
- outputDir: path.join(e2eDir, 'test-results'),
46
+ outputDir: path.join(path.dirname(appDir), 'test-results'),
40
47
  use: {
41
48
  baseURL: `http://localhost:${port}`,
42
49
  trace: 'on-first-retry'
@@ -49,16 +56,36 @@ function createPlaywrightConfig({ packageDir, port: defaultPort = 3001 }) {
49
56
  }
50
57
  }
51
58
  ],
52
- webServer: {
53
- command: [
54
- `node ${prepareServerPath} --config-directory ${appDir} --server-directory ${serverDir} --log-level warn`,
55
- `node ${cliPath} build --config-directory ${appDir} --server-directory ${serverDir}`,
56
- `node ${cliPath} start --config-directory ${appDir} --server-directory ${serverDir} --port ${port} --log-level warn`
57
- ].join(' && '),
58
- url: `http://localhost:${port}`,
59
- reuseExistingServer: process.env.LOWDEFY_E2E_REUSE_SERVER === 'true',
60
- timeout: 180000
61
- }
59
+ webServer: [
60
+ ...services.map((service)=>({
61
+ reuseExistingServer,
62
+ ...service
63
+ })),
64
+ {
65
+ command: [
66
+ `node ${prepareServerPath} --config-directory ${appDir} --server-directory ${serverDir} --log-level warn`,
67
+ `node ${cliPath} build --config-directory ${appDir} --server-directory ${serverDir}`,
68
+ `node ${cliPath} start --config-directory ${appDir} --server-directory ${serverDir} --port ${port} --log-level warn`
69
+ ].join(' && '),
70
+ url: `http://localhost:${port}`,
71
+ reuseExistingServer,
72
+ timeout: 180000,
73
+ env: env === undefined ? undefined : {
74
+ ...process.env,
75
+ ...env
76
+ },
77
+ // Playwright stops the web servers in reverse order, the app first. Killed outright, the
78
+ // server that `lowdefy start` runs outlives its shell, so it was still connected when the
79
+ // services (a database) stopped under it. A SIGTERM to the app's process group, waited
80
+ // for, stops it before the services.
81
+ ...services.length > 0 ? {
82
+ gracefulShutdown: {
83
+ signal: 'SIGTERM',
84
+ timeout: 15000
85
+ }
86
+ } : {}
87
+ }
88
+ ]
62
89
  });
63
90
  }
64
91
  export default createPlaywrightConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/block-dev-e2e",
3
- "version": "0.0.0-experimental-20260929135001",
3
+ "version": "0.0.0-experimental-20260930181833",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Lowdefy Block E2E Testing Tools",
6
6
  "homepage": "https://lowdefy.com",
@@ -29,7 +29,7 @@
29
29
  "dist/*"
30
30
  ],
31
31
  "dependencies": {
32
- "@lowdefy/e2e-utils": "0.0.0-experimental-20260929135001",
32
+ "@lowdefy/e2e-utils": "0.0.0-experimental-20260930181833",
33
33
  "@playwright/test": "1.59.1"
34
34
  },
35
35
  "devDependencies": {