@zitadel/testing 0.0.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supervisor.cjs","names":["parseSupervisorConfig","SUPERVISOR_CONFIG_ENV","requireHandshakePath","startLocalZitadel","writeHandshake"],"sources":["../src/supervisor.ts"],"sourcesContent":["/**\n * Playwright webServer entry generated by `withZitadel()`: boots an ephemeral\n * seeded Zitadel and writes the handshake file that the app runner and the\n * test fixtures read. Stays in the foreground; SIGTERM/SIGINT stop the\n * instance. Configuration arrives as JSON in ZITADEL_TESTING_SUPERVISOR.\n */\nimport { access, rm } from \"node:fs/promises\";\n\nimport { writeHandshake } from \"./handshake\";\nimport { startLocalZitadel } from \"./index\";\nimport { parseSupervisorConfig, requireHandshakePath, SUPERVISOR_CONFIG_ENV } from \"./orchestration\";\nimport type { LocalZitadel } from \"./types\";\n\nconst LOG = \"[zitadel-testing]\";\n\nasync function main(): Promise<void> {\n const config = parseSupervisorConfig(process.env[SUPERVISOR_CONFIG_ENV]);\n const handshakePath = requireHandshakePath(process.env);\n\n if (config.serverBinary) {\n // In-repo platform packages ship no binary; fail fast with the fix.\n await access(config.serverBinary).catch(() => {\n console.error(\n `${LOG} server binary not found at ${config.serverBinary}` +\n (config.serverBinaryHint ? ` — ${config.serverBinaryHint}` : \"\"),\n );\n process.exit(1);\n });\n }\n\n // Signal handlers close over this binding before the asynchronous boot\n // assigns it.\n // oxlint-disable-next-line prefer-const\n let zitadel: LocalZitadel | undefined;\n let signalled = false;\n let finishing: Promise<void> | undefined;\n\n const finish = (code: number): Promise<void> => {\n finishing ??= (async () => {\n let exitCode = code;\n try {\n await zitadel?.stop();\n } catch (error) {\n console.error(`${LOG} stop failed: ${(error as Error).message}`);\n exitCode = 1;\n }\n await rm(handshakePath, { force: true }).catch(() => undefined);\n process.exit(exitCode);\n })();\n return finishing;\n };\n\n // Handlers are installed before the boot so a cancellation arriving while\n // the instance comes up (or before the handshake is written) still tears it\n // down.\n const onSignal = (signal: NodeJS.Signals): void => {\n signalled = true;\n console.log(\n `${LOG} ${signal} received${zitadel ? \", stopping instance\" : \" during boot; stopping once ready\"}`,\n );\n if (zitadel) {\n void finish(0);\n }\n };\n process.on(\"SIGTERM\", onSignal);\n process.on(\"SIGINT\", onSignal);\n\n await rm(handshakePath, { force: true });\n\n zitadel = await startLocalZitadel({\n port: config.port,\n appOrigins: config.appOrigins,\n serverBinary: config.serverBinary,\n dir: config.dir,\n keep: config.keep,\n projectName: config.projectName,\n preset: config.preset,\n useCase: config.useCase,\n timeoutMs: config.timeoutMs,\n });\n if (signalled) {\n await finish(0);\n return;\n }\n\n try {\n await writeHandshake(handshakePath, zitadel.handle);\n } catch (error) {\n console.error(`${LOG} failed to write handshake: ${(error as Error).message}`);\n await finish(1);\n return;\n }\n console.log(\n `${LOG} instance ready at ${zitadel.handle.baseUrl} (project ${zitadel.handle.projectId})`,\n );\n\n setInterval(() => {\n /* keep the event loop alive; Playwright owns this process's lifetime */\n }, 60_000);\n}\n\nmain().catch((error: unknown) => {\n console.error(`${LOG} ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;AAaA,MAAM,MAAM;AAEZ,eAAe,OAAsB;CACnC,MAAM,SAASA,sBAAAA,sBAAsB,QAAQ,IAAIC,sBAAAA,uBAAuB;CACxE,MAAM,gBAAgBC,sBAAAA,qBAAqB,QAAQ,IAAI;AAEvD,KAAI,OAAO,aAET,QAAA,GAAA,iBAAA,QAAa,OAAO,aAAa,CAAC,YAAY;AAC5C,UAAQ,MACN,GAAG,IAAI,8BAA8B,OAAO,kBACzC,OAAO,mBAAmB,MAAM,OAAO,qBAAqB,IAChE;AACD,UAAQ,KAAK,EAAE;GACf;CAMJ,IAAI;CACJ,IAAI,YAAY;CAChB,IAAI;CAEJ,MAAM,UAAU,SAAgC;AAC9C,iBAAe,YAAY;GACzB,IAAI,WAAW;AACf,OA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ake } from "./handshake-BPtWruO8.mjs";
2
+ import { n as startLocalZitadel } from "./src-DkG0V4A6.mjs";
3
+ import { a as parseSupervisorConfig, o as requireHandshakePath, r as SUPERVISOR_CONFIG_ENV } from "./orchestration-C640_1Lg.mjs";
4
+ import { access, rm } from "node:fs/promises";
5
+ //#region src/supervisor.ts
6
+ /**
7
+ * Playwright webServer entry generated by `withZitadel()`: boots an ephemeral
8
+ * seeded Zitadel and writes the handshake file that the app runner and the
9
+ * test fixtures read. Stays in the foreground; SIGTERM/SIGINT stop the
10
+ * instance. Configuration arrives as JSON in ZITADEL_TESTING_SUPERVISOR.
11
+ */
12
+ const LOG = "[zitadel-testing]";
13
+ async function main() {
14
+ const config = parseSupervisorConfig(process.env[SUPERVISOR_CONFIG_ENV]);
15
+ const handshakePath = requireHandshakePath(process.env);
16
+ if (config.serverBinary) await access(config.serverBinary).catch(() => {
17
+ console.error(`${LOG} server binary not found at ${config.serverBinary}` + (config.serverBinaryHint ? ` — ${config.serverBinaryHint}` : ""));
18
+ process.exit(1);
19
+ });
20
+ let zitadel;
21
+ let signalled = false;
22
+ let finishing;
23
+ const finish = (code) => {
24
+ finishing ??= (async () => {
25
+ let exitCode = code;
26
+ try {
27
+ await zitadel?.stop();
28
+ } catch (error) {
29
+ console.error(`${LOG} stop failed: ${error.message}`);
30
+ exitCode = 1;
31
+ }
32
+ await rm(handshakePath, { force: true }).catch(() => void 0);
33
+ process.exit(exitCode);
34
+ })();
35
+ return finishing;
36
+ };
37
+ const onSignal = (signal) => {
38
+ signalled = true;
39
+ console.log(`${LOG} ${signal} received${zitadel ? ", stopping instance" : " during boot; stopping once ready"}`);
40
+ if (zitadel) finish(0);
41
+ };
42
+ process.on("SIGTERM", onSignal);
43
+ process.on("SIGINT", onSignal);
44
+ await rm(handshakePath, { force: true });
45
+ zitadel = await startLocalZitadel({
46
+ port: config.port,
47
+ appOrigins: config.appOrigins,
48
+ serverBinary: config.serverBinary,
49
+ dir: config.dir,
50
+ keep: config.keep,
51
+ projectName: config.projectName,
52
+ preset: config.preset,
53
+ useCase: config.useCase,
54
+ timeoutMs: config.timeoutMs
55
+ });
56
+ if (signalled) {
57
+ await finish(0);
58
+ return;
59
+ }
60
+ try {
61
+ await writeHandshake(handshakePath, zitadel.handle);
62
+ } catch (error) {
63
+ console.error(`${LOG} failed to write handshake: ${error.message}`);
64
+ await finish(1);
65
+ return;
66
+ }
67
+ console.log(`${LOG} instance ready at ${zitadel.handle.baseUrl} (project ${zitadel.handle.projectId})`);
68
+ setInterval(() => {}, 6e4);
69
+ }
70
+ main().catch((error) => {
71
+ console.error(`${LOG} ${error instanceof Error ? error.message : String(error)}`);
72
+ process.exit(1);
73
+ });
74
+ //#endregion
75
+ export {};
76
+
77
+ //# sourceMappingURL=supervisor.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supervisor.mjs","names":[],"sources":["../src/supervisor.ts"],"sourcesContent":["/**\n * Playwright webServer entry generated by `withZitadel()`: boots an ephemeral\n * seeded Zitadel and writes the handshake file that the app runner and the\n * test fixtures read. Stays in the foreground; SIGTERM/SIGINT stop the\n * instance. Configuration arrives as JSON in ZITADEL_TESTING_SUPERVISOR.\n */\nimport { access, rm } from \"node:fs/promises\";\n\nimport { writeHandshake } from \"./handshake\";\nimport { startLocalZitadel } from \"./index\";\nimport { parseSupervisorConfig, requireHandshakePath, SUPERVISOR_CONFIG_ENV } from \"./orchestration\";\nimport type { LocalZitadel } from \"./types\";\n\nconst LOG = \"[zitadel-testing]\";\n\nasync function main(): Promise<void> {\n const config = parseSupervisorConfig(process.env[SUPERVISOR_CONFIG_ENV]);\n const handshakePath = requireHandshakePath(process.env);\n\n if (config.serverBinary) {\n // In-repo platform packages ship no binary; fail fast with the fix.\n await access(config.serverBinary).catch(() => {\n console.error(\n `${LOG} server binary not found at ${config.serverBinary}` +\n (config.serverBinaryHint ? ` — ${config.serverBinaryHint}` : \"\"),\n );\n process.exit(1);\n });\n }\n\n // Signal handlers close over this binding before the asynchronous boot\n // assigns it.\n // oxlint-disable-next-line prefer-const\n let zitadel: LocalZitadel | undefined;\n let signalled = false;\n let finishing: Promise<void> | undefined;\n\n const finish = (code: number): Promise<void> => {\n finishing ??= (async () => {\n let exitCode = code;\n try {\n await zitadel?.stop();\n } catch (error) {\n console.error(`${LOG} stop failed: ${(error as Error).message}`);\n exitCode = 1;\n }\n await rm(handshakePath, { force: true }).catch(() => undefined);\n process.exit(exitCode);\n })();\n return finishing;\n };\n\n // Handlers are installed before the boot so a cancellation arriving while\n // the instance comes up (or before the handshake is written) still tears it\n // down.\n const onSignal = (signal: NodeJS.Signals): void => {\n signalled = true;\n console.log(\n `${LOG} ${signal} received${zitadel ? \", stopping instance\" : \" during boot; stopping once ready\"}`,\n );\n if (zitadel) {\n void finish(0);\n }\n };\n process.on(\"SIGTERM\", onSignal);\n process.on(\"SIGINT\", onSignal);\n\n await rm(handshakePath, { force: true });\n\n zitadel = await startLocalZitadel({\n port: config.port,\n appOrigins: config.appOrigins,\n serverBinary: config.serverBinary,\n dir: config.dir,\n keep: config.keep,\n projectName: config.projectName,\n preset: config.preset,\n useCase: config.useCase,\n timeoutMs: config.timeoutMs,\n });\n if (signalled) {\n await finish(0);\n return;\n }\n\n try {\n await writeHandshake(handshakePath, zitadel.handle);\n } catch (error) {\n console.error(`${LOG} failed to write handshake: ${(error as Error).message}`);\n await finish(1);\n return;\n }\n console.log(\n `${LOG} instance ready at ${zitadel.handle.baseUrl} (project ${zitadel.handle.projectId})`,\n );\n\n setInterval(() => {\n /* keep the event loop alive; Playwright owns this process's lifetime */\n }, 60_000);\n}\n\nmain().catch((error: unknown) => {\n console.error(`${LOG} ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;AAaA,MAAM,MAAM;AAEZ,eAAe,OAAsB;CACnC,MAAM,SAAS,sBAAsB,QAAQ,IAAI,uBAAuB;CACxE,MAAM,gBAAgB,qBAAqB,QAAQ,IAAI;AAEvD,KAAI,OAAO,a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,mBAAkB,IAEf,IAAO;;AAGZ,MAAM,CAAC,OAAO,UAAmB;AAC/B,SAAQ,MAAM,GAAG,IAAI,GAAG,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,GAAG;AACjF,SAAQ,KAAK,EAAE;EACf"}
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "@zitadel/testing",
3
+ "version": "0.0.0",
4
+ "description": "Test-kit for seeded ephemeral local Zitadel instances",
5
+ "homepage": "https://github.com/zitadel/nextgen/tree/main/packages/testing#readme",
6
+ "bugs": {
7
+ "url": "https://github.com/zitadel/nextgen/issues"
8
+ },
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/zitadel/nextgen.git",
13
+ "directory": "packages/testing"
14
+ },
15
+ "type": "module",
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "exports": {
23
+ ".": {
24
+ "@zitadel/source": "./src/index.ts",
25
+ "types": "./dist/index.d.mts",
26
+ "import": "./dist/index.mjs",
27
+ "require": "./dist/index.cjs",
28
+ "default": "./dist/index.mjs"
29
+ },
30
+ "./playwright": {
31
+ "@zitadel/source": "./src/playwright.ts",
32
+ "types": "./dist/playwright.d.mts",
33
+ "import": "./dist/playwright.mjs",
34
+ "require": "./dist/playwright.cjs",
35
+ "default": "./dist/playwright.mjs"
36
+ },
37
+ "./package.json": "./package.json"
38
+ },
39
+ "dependencies": {
40
+ "@zitadel/cli": "0.1.0-alpha.17",
41
+ "@zitadel/api": "0.1.0-alpha.17",
42
+ "@zitadel/config": "0.1.0-alpha.17"
43
+ },
44
+ "peerDependencies": {
45
+ "@playwright/test": ">=1.60"
46
+ },
47
+ "peerDependenciesMeta": {
48
+ "@playwright/test": {
49
+ "optional": true
50
+ }
51
+ },
52
+ "devDependencies": {
53
+ "@playwright/test": "^1.60.0",
54
+ "msw": "^2.14.6",
55
+ "tsdown": "^0.21.10",
56
+ "tslib": "^2.8.1",
57
+ "vitest": "^4.1.9"
58
+ },
59
+ "scripts": {
60
+ "build": "tsdown",
61
+ "typecheck": "tsc --noEmit -p tsconfig.json",
62
+ "test": "vitest run",
63
+ "test:integration": "vitest run --config vitest.integration.config.ts",
64
+ "lint": "oxlint ."
65
+ }
66
+ }