@virtocommerce/test-automation-framework 0.0.0-stage → 0.1.0-alpha.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/.biome/formatter.json +11 -0
- package/.biome/imports.json +52 -0
- package/.biome/preset.json +4 -0
- package/.biome/rules.json +45 -0
- package/.claude/agents/qa-automation-expert.md +119 -0
- package/.claude/agents/qa-coverage.md +96 -0
- package/.claude/agents/qa-explorer.md +112 -0
- package/.claude/agents/qa-healer.md +88 -0
- package/.claude/agents/qa-judge.md +102 -0
- package/.claude/agents/qa-planner.md +104 -0
- package/.claude/agents/qa-reviewer.md +121 -0
- package/.claude/checks/browser-secrets.mts +107 -0
- package/.claude/checks/contract.mts +469 -0
- package/.claude/checks/expectation-guard.mts +665 -0
- package/.claude/checks/explore-extractors.mts +4 -0
- package/.claude/checks/judge-verdict.mts +165 -0
- package/.claude/checks/project-facts.mts +491 -0
- package/.claude/checks/prove-fails.mts +770 -0
- package/.claude/checks/rank-gaps.mts +177 -0
- package/.claude/checks/readonly-shell.mts +740 -0
- package/.claude/checks/reconcile-run.mts +270 -0
- package/.claude/checks/scan-prompts.mts +351 -0
- package/.claude/checks/stand.mts +45 -0
- package/.claude/checks/test-duration.mts +134 -0
- package/.claude/checks/test-shape.mts +224 -0
- package/.claude/checks/ticket-card.mts +195 -0
- package/.claude/commands/qa-coverage.md +13 -0
- package/.claude/commands/qa-explore.md +17 -0
- package/.claude/commands/qa-heal.md +44 -0
- package/.claude/commands/qa-implement.md +60 -0
- package/.claude/commands/qa-plan.md +55 -0
- package/.claude/commands/qa-review.md +90 -0
- package/.claude/commands/qa.md +156 -0
- package/.claude/hooks/readonly-shell.mts +65 -0
- package/.claude/settings.json +15 -0
- package/.claude/skills/coverage-analysis/SKILL.md +107 -0
- package/.claude/skills/create-graphql-layer/SKILL.md +159 -0
- package/.claude/skills/create-ui-layer/SKILL.md +189 -0
- package/.claude/skills/explore-api/SKILL.md +74 -0
- package/.claude/skills/explore-frontend/SKILL.md +85 -0
- package/.claude/skills/framework-rules/SKILL.md +189 -0
- package/.claude/skills/heal-tests/SKILL.md +197 -0
- package/.claude/skills/heal-tests/guard-recipe.md +53 -0
- package/.claude/skills/judge-criteria/SKILL.md +40 -0
- package/.claude/skills/judge-criteria/coverage.md +9 -0
- package/.claude/skills/judge-criteria/expert.md +23 -0
- package/.claude/skills/judge-criteria/explorer.md +9 -0
- package/.claude/skills/judge-criteria/healer.md +13 -0
- package/.claude/skills/judge-criteria/planner.md +12 -0
- package/.claude/skills/plan-implementation/SKILL.md +82 -0
- package/.claude/skills/plan-implementation/contract-template.md +72 -0
- package/.claude/skills/plan-test-strategy/SKILL.md +100 -0
- package/.claude/skills/project-facts/SKILL.md +130 -0
- package/.claude/skills/read-change/SKILL.md +64 -0
- package/.claude/skills/read-ticket/SKILL.md +63 -0
- package/.claude/skills/read-ticket/providers.md +58 -0
- package/.claude/skills/review-pr/SKILL.md +152 -0
- package/.claude/skills/review-test-code/SKILL.md +208 -0
- package/.claude/skills/write-e2e-test/SKILL.md +175 -0
- package/.claude/skills/write-graphql-test/SKILL.md +158 -0
- package/.claude/skills/write-rest-api-test/SKILL.md +182 -0
- package/.claude/skills/write-security-test/SKILL.md +253 -0
- package/.qa/project.example.json +71 -0
- package/CHANGELOG.md +1 -0
- package/LICENSE +12 -0
- package/README.md +53 -2
- package/bin/install-qa-agents.mjs +94 -0
- package/dist/auth/credentials.d.ts +10 -0
- package/dist/auth/credentials.js +2 -0
- package/dist/auth/credentials.js.map +1 -0
- package/dist/auth/frontend-browser-sessions.d.ts +71 -0
- package/dist/auth/frontend-browser-sessions.js +130 -0
- package/dist/auth/frontend-browser-sessions.js.map +1 -0
- package/dist/auth/index.d.ts +9 -0
- package/dist/auth/index.js +5 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/platform-browser-sessions.d.ts +47 -0
- package/dist/auth/platform-browser-sessions.js +92 -0
- package/dist/auth/platform-browser-sessions.js.map +1 -0
- package/dist/auth/sign-in-lock.d.ts +14 -0
- package/dist/auth/sign-in-lock.js +70 -0
- package/dist/auth/sign-in-lock.js.map +1 -0
- package/dist/auth/storage-state.d.ts +3 -0
- package/dist/auth/storage-state.js +2 -0
- package/dist/auth/storage-state.js.map +1 -0
- package/dist/auth/token-client.d.ts +82 -0
- package/dist/auth/token-client.js +111 -0
- package/dist/auth/token-client.js.map +1 -0
- package/dist/auth/token-manager.d.ts +67 -0
- package/dist/auth/token-manager.js +138 -0
- package/dist/auth/token-manager.js.map +1 -0
- package/dist/core/default-reporters.d.ts +31 -0
- package/dist/core/default-reporters.js +36 -0
- package/dist/core/default-reporters.js.map +1 -0
- package/dist/core/default-use.d.ts +28 -0
- package/dist/core/default-use.js +25 -0
- package/dist/core/default-use.js.map +1 -0
- package/dist/core/env.d.ts +24 -0
- package/dist/core/env.js +33 -0
- package/dist/core/env.js.map +1 -0
- package/dist/core/error-message.d.ts +10 -0
- package/dist/core/error-message.js +13 -0
- package/dist/core/error-message.js.map +1 -0
- package/dist/core/index.d.ts +16 -0
- package/dist/core/index.js +11 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/is-ci.d.ts +14 -0
- package/dist/core/is-ci.js +18 -0
- package/dist/core/is-ci.js.map +1 -0
- package/dist/core/parse-env.d.ts +13 -0
- package/dist/core/parse-env.js +21 -0
- package/dist/core/parse-env.js.map +1 -0
- package/dist/core/projects.d.ts +24 -0
- package/dist/core/projects.js +33 -0
- package/dist/core/projects.js.map +1 -0
- package/dist/core/run-options.d.ts +31 -0
- package/dist/core/run-options.js +43 -0
- package/dist/core/run-options.js.map +1 -0
- package/dist/core/secret.d.ts +105 -0
- package/dist/core/secret.js +167 -0
- package/dist/core/secret.js.map +1 -0
- package/dist/core/string-schemas.d.ts +39 -0
- package/dist/core/string-schemas.js +56 -0
- package/dist/core/string-schemas.js.map +1 -0
- package/dist/core/url-path.d.ts +7 -0
- package/dist/core/url-path.js +2 -0
- package/dist/core/url-path.js.map +1 -0
- package/dist/dataset/collection.d.ts +44 -0
- package/dist/dataset/collection.js +76 -0
- package/dist/dataset/collection.js.map +1 -0
- package/dist/dataset/index.d.ts +11 -0
- package/dist/dataset/index.js +6 -0
- package/dist/dataset/index.js.map +1 -0
- package/dist/dataset/load-dataset.d.ts +39 -0
- package/dist/dataset/load-dataset.js +62 -0
- package/dist/dataset/load-dataset.js.map +1 -0
- package/dist/dataset/manifest.d.ts +77 -0
- package/dist/dataset/manifest.js +10 -0
- package/dist/dataset/manifest.js.map +1 -0
- package/dist/dataset/placeholders.d.ts +66 -0
- package/dist/dataset/placeholders.js +87 -0
- package/dist/dataset/placeholders.js.map +1 -0
- package/dist/dataset/seed-collection.d.ts +53 -0
- package/dist/dataset/seed-collection.js +115 -0
- package/dist/dataset/seed-collection.js.map +1 -0
- package/dist/dataset/seed-dataset.d.ts +70 -0
- package/dist/dataset/seed-dataset.js +138 -0
- package/dist/dataset/seed-dataset.js.map +1 -0
- package/dist/dataset/seed-events.d.ts +81 -0
- package/dist/dataset/seed-events.js +2 -0
- package/dist/dataset/seed-events.js.map +1 -0
- package/dist/dataset/seed-requests.d.ts +102 -0
- package/dist/dataset/seed-requests.js +160 -0
- package/dist/dataset/seed-requests.js.map +1 -0
- package/dist/dataset/seed-scope.d.ts +39 -0
- package/dist/dataset/seed-scope.js +67 -0
- package/dist/dataset/seed-scope.js.map +1 -0
- package/dist/fixtures/default-fixtures.d.ts +93 -0
- package/dist/fixtures/default-fixtures.js +105 -0
- package/dist/fixtures/default-fixtures.js.map +1 -0
- package/dist/fixtures/index.d.ts +2 -0
- package/dist/fixtures/index.js +2 -0
- package/dist/fixtures/index.js.map +1 -0
- package/dist/graphql/graphql-client.d.ts +78 -0
- package/dist/graphql/graphql-client.js +83 -0
- package/dist/graphql/graphql-client.js.map +1 -0
- package/dist/graphql/graphql-codegen.d.ts +56 -0
- package/dist/graphql/graphql-codegen.js +42 -0
- package/dist/graphql/graphql-codegen.js.map +1 -0
- package/dist/graphql/graphql-error.d.ts +54 -0
- package/dist/graphql/graphql-error.js +74 -0
- package/dist/graphql/graphql-error.js.map +1 -0
- package/dist/graphql/index.d.ts +6 -0
- package/dist/graphql/index.js +4 -0
- package/dist/graphql/index.js.map +1 -0
- package/dist/http/authentication.d.ts +16 -0
- package/dist/http/authentication.js +2 -0
- package/dist/http/authentication.js.map +1 -0
- package/dist/http/http-client.d.ts +110 -0
- package/dist/http/http-client.js +237 -0
- package/dist/http/http-client.js.map +1 -0
- package/dist/http/http-error.d.ts +26 -0
- package/dist/http/http-error.js +34 -0
- package/dist/http/http-error.js.map +1 -0
- package/dist/http/http-method.d.ts +2 -0
- package/dist/http/http-method.js +2 -0
- package/dist/http/http-method.js.map +1 -0
- package/dist/http/http-response.d.ts +137 -0
- package/dist/http/http-response.js +166 -0
- package/dist/http/http-response.js.map +1 -0
- package/dist/http/index.d.ts +7 -0
- package/dist/http/index.js +4 -0
- package/dist/http/index.js.map +1 -0
- package/dist/http/request-options.d.ts +62 -0
- package/dist/http/request-options.js +2 -0
- package/dist/http/request-options.js.map +1 -0
- package/dist/modules/index.d.ts +2 -0
- package/dist/modules/index.js +2 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/modules/installed-modules.d.ts +86 -0
- package/dist/modules/installed-modules.js +135 -0
- package/dist/modules/installed-modules.js.map +1 -0
- package/docs/README.md +43 -0
- package/docs/concepts/areas.md +38 -0
- package/docs/concepts/auth.md +92 -0
- package/docs/concepts/config.md +102 -0
- package/docs/concepts/dataset.md +183 -0
- package/docs/concepts/environment.md +54 -0
- package/docs/concepts/fixtures.md +109 -0
- package/docs/concepts/graphql.md +76 -0
- package/docs/concepts/http.md +88 -0
- package/docs/concepts/modules.md +63 -0
- package/docs/concepts/secrets.md +50 -0
- package/docs/contributing/architecture.md +67 -0
- package/docs/contributing/conventions.md +39 -0
- package/docs/contributing/documentation.md +37 -0
- package/docs/contributing/releasing.md +76 -0
- package/docs/examples/auth.ts +20 -0
- package/docs/examples/config.ts +36 -0
- package/docs/examples/dataset.ts +70 -0
- package/docs/examples/environment.ts +8 -0
- package/docs/examples/fixtures.ts +41 -0
- package/docs/examples/getting-started.ts +22 -0
- package/docs/examples/graphql-codegen.ts +9 -0
- package/docs/examples/graphql.ts +32 -0
- package/docs/examples/http.ts +18 -0
- package/docs/examples/modules.ts +19 -0
- package/docs/examples/secrets.ts +11 -0
- package/docs/examples/tsconfig.json +10 -0
- package/docs/getting-started.md +106 -0
- package/docs/guides/generating-types.md +75 -0
- package/docs/guides/qa-agents.md +66 -0
- package/package.json +156 -4
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the base `use` options of a test suite: the certificate check from the environment, and the evidence of
|
|
3
|
+
* failed tests.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* A failed test keeps its trace, a screenshot and a video; a passed test keeps none. Screenshots and videos apply only
|
|
7
|
+
* to tests that use a browser.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* use: { ...defaultUse(env), baseURL: env.FRONTEND_BASE_URL },
|
|
11
|
+
*
|
|
12
|
+
* @param env - The parsed environment variables.
|
|
13
|
+
* @param options - The test id attribute.
|
|
14
|
+
* @returns The options, for the `use` option of the Playwright config or of a project.
|
|
15
|
+
*/
|
|
16
|
+
export function defaultUse(env, options = {}) {
|
|
17
|
+
return {
|
|
18
|
+
ignoreHTTPSErrors: !env.VERIFY_SSL,
|
|
19
|
+
trace: "retain-on-failure",
|
|
20
|
+
screenshot: "only-on-failure",
|
|
21
|
+
video: "retain-on-failure",
|
|
22
|
+
testIdAttribute: options.testIdAttribute ?? "data-test-id",
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=default-use.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-use.js","sourceRoot":"","sources":["../../src/core/default-use.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,UAAU,CAAC,GAAQ,EAAE,OAAO,GAAsB,EAAE;IAClE,OAAO;QACL,iBAAiB,EAAE,CAAC,GAAG,CAAC,UAAU;QAClC,KAAK,EAAE,mBAAmB;QAC1B,UAAU,EAAE,iBAAiB;QAC7B,KAAK,EAAE,mBAAmB;QAC1B,eAAe,EAAE,OAAO,CAAC,eAAe,IAAI,cAAc;KAC3D,CAAC;AACJ,CAAC","sourcesContent":["import type { PlaywrightTestOptions, PlaywrightWorkerOptions } from \"@playwright/test\";\nimport type { Env } from \"./env.ts\";\n\n/** The options of {@link defaultUse}. */\nexport interface DefaultUseOptions {\n /**\n * The attribute that `getByTestId` reads. The default is `data-test-id`, the attribute of the Virto Commerce\n * frontend.\n */\n readonly testIdAttribute?: string | undefined;\n}\n\n/** The base `use` options of a test suite, as {@link defaultUse} returns them. */\nexport type DefaultUse = Pick<\n PlaywrightTestOptions & PlaywrightWorkerOptions,\n \"ignoreHTTPSErrors\" | \"trace\" | \"screenshot\" | \"video\" | \"testIdAttribute\"\n>;\n\n/**\n * Returns the base `use` options of a test suite: the certificate check from the environment, and the evidence of\n * failed tests.\n *\n * @remarks\n * A failed test keeps its trace, a screenshot and a video; a passed test keeps none. Screenshots and videos apply only\n * to tests that use a browser.\n *\n * @example\n * use: { ...defaultUse(env), baseURL: env.FRONTEND_BASE_URL },\n *\n * @param env - The parsed environment variables.\n * @param options - The test id attribute.\n * @returns The options, for the `use` option of the Playwright config or of a project.\n */\nexport function defaultUse(env: Env, options: DefaultUseOptions = {}): DefaultUse {\n return {\n ignoreHTTPSErrors: !env.VERIFY_SSL,\n trace: \"retain-on-failure\",\n screenshot: \"only-on-failure\",\n video: \"retain-on-failure\",\n testIdAttribute: options.testIdAttribute ?? \"data-test-id\",\n };\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { output } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* The environment variables that every Virto Commerce-based solution needs.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Test suites extend this schema with their own variables. They can also redefine a variable to change its default.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const suiteEnvSchema = envSchema.extend({ API_WORKERS: positiveInt.default(8), MAILBOX_URL: absoluteUrl });
|
|
10
|
+
* const env = parseEnv(suiteEnvSchema);
|
|
11
|
+
*/
|
|
12
|
+
export declare const envSchema: import("zod").ZodObject<{
|
|
13
|
+
BACKEND_BASE_URL: import("zod").ZodPipe<import("zod").ZodURL, import("zod").ZodTransform<string, string>>;
|
|
14
|
+
ADMIN_USERNAME: import("zod").ZodString;
|
|
15
|
+
ADMIN_PASSWORD: import("zod").ZodPipe<import("zod").ZodString, import("zod").ZodTransform<import("./secret.ts").Secret, string>>;
|
|
16
|
+
VERIFY_SSL: import("zod").ZodDefault<import("zod").ZodPipe<import("zod").ZodString, import("zod").ZodTransform<boolean, string>>>;
|
|
17
|
+
REQUEST_TIMEOUT_MS: import("zod").ZodDefault<import("zod").ZodPipe<import("zod").ZodPipe<import("zod").ZodString, import("zod").ZodTransform<number, string>>, import("zod").ZodNumber>>;
|
|
18
|
+
RUN_DESTRUCTIVE_TESTS: import("zod").ZodDefault<import("zod").ZodPipe<import("zod").ZodString, import("zod").ZodTransform<boolean, string>>>;
|
|
19
|
+
SKIP_PLATFORM_DEFECTS: import("zod").ZodDefault<import("zod").ZodPipe<import("zod").ZodString, import("zod").ZodTransform<boolean, string>>>;
|
|
20
|
+
API_WORKERS: import("zod").ZodDefault<import("zod").ZodPipe<import("zod").ZodPipe<import("zod").ZodString, import("zod").ZodTransform<number, string>>, import("zod").ZodNumber>>;
|
|
21
|
+
E2E_WORKERS: import("zod").ZodDefault<import("zod").ZodPipe<import("zod").ZodPipe<import("zod").ZodString, import("zod").ZodTransform<number, string>>, import("zod").ZodNumber>>;
|
|
22
|
+
}, import("zod/v4/core").$strip>;
|
|
23
|
+
/** The environment variables parsed by {@link envSchema}. */
|
|
24
|
+
export type Env = output<typeof envSchema>;
|
package/dist/core/env.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { object } from "zod";
|
|
2
|
+
import { booleanString, nonBlankString, originUrl, positiveInt, secretString } from "./string-schemas.js";
|
|
3
|
+
/**
|
|
4
|
+
* The environment variables that every Virto Commerce-based solution needs.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Test suites extend this schema with their own variables. They can also redefine a variable to change its default.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const suiteEnvSchema = envSchema.extend({ API_WORKERS: positiveInt.default(8), MAILBOX_URL: absoluteUrl });
|
|
11
|
+
* const env = parseEnv(suiteEnvSchema);
|
|
12
|
+
*/
|
|
13
|
+
export const envSchema = object({
|
|
14
|
+
/** The origin of the Virto Commerce platform, such as `https://platform.example.com`. */
|
|
15
|
+
BACKEND_BASE_URL: originUrl,
|
|
16
|
+
/** The user name of the platform administrator account that the tests sign in with. */
|
|
17
|
+
ADMIN_USERNAME: nonBlankString,
|
|
18
|
+
/** The password of the platform administrator account. */
|
|
19
|
+
ADMIN_PASSWORD: secretString,
|
|
20
|
+
/** Whether to verify the TLS certificate of the platform. The default is `true`. */
|
|
21
|
+
VERIFY_SSL: booleanString.default(true),
|
|
22
|
+
/** The time to wait for a response, in milliseconds. The default is 30000. */
|
|
23
|
+
REQUEST_TIMEOUT_MS: positiveInt.default(30_000),
|
|
24
|
+
/** Whether to run tests that delete or change shared data. The default is `false`. */
|
|
25
|
+
RUN_DESTRUCTIVE_TESTS: booleanString.default(false),
|
|
26
|
+
/** Whether to leave out tests that fail because of a known platform defect. The default is `false`. */
|
|
27
|
+
SKIP_PLATFORM_DEFECTS: booleanString.default(false),
|
|
28
|
+
/** The number of workers that run API tests, such as REST and GraphQL tests. The default is 4. */
|
|
29
|
+
API_WORKERS: positiveInt.default(4),
|
|
30
|
+
/** The number of workers that run end-to-end browser tests. The default is 3. */
|
|
31
|
+
E2E_WORKERS: positiveInt.default(3),
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=env.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/core/env.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAE7B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAE1G;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC;IAC9B,yFAAyF;IACzF,gBAAgB,EAAE,SAAS;IAC3B,uFAAuF;IACvF,cAAc,EAAE,cAAc;IAC9B,0DAA0D;IAC1D,cAAc,EAAE,YAAY;IAC5B,oFAAoF;IACpF,UAAU,EAAE,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC;IACvC,8EAA8E;IAC9E,kBAAkB,EAAE,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC;IAC/C,sFAAsF;IACtF,qBAAqB,EAAE,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC;IACnD,uGAAuG;IACvG,qBAAqB,EAAE,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC;IACnD,kGAAkG;IAClG,WAAW,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;IACnC,iFAAiF;IACjF,WAAW,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;CACpC,CAAC,CAAC","sourcesContent":["import type { output } from \"zod\";\n\nimport { object } from \"zod\";\n\nimport { booleanString, nonBlankString, originUrl, positiveInt, secretString } from \"./string-schemas.ts\";\n\n/**\n * The environment variables that every Virto Commerce-based solution needs.\n *\n * @remarks\n * Test suites extend this schema with their own variables. They can also redefine a variable to change its default.\n *\n * @example\n * const suiteEnvSchema = envSchema.extend({ API_WORKERS: positiveInt.default(8), MAILBOX_URL: absoluteUrl });\n * const env = parseEnv(suiteEnvSchema);\n */\nexport const envSchema = object({\n /** The origin of the Virto Commerce platform, such as `https://platform.example.com`. */\n BACKEND_BASE_URL: originUrl,\n /** The user name of the platform administrator account that the tests sign in with. */\n ADMIN_USERNAME: nonBlankString,\n /** The password of the platform administrator account. */\n ADMIN_PASSWORD: secretString,\n /** Whether to verify the TLS certificate of the platform. The default is `true`. */\n VERIFY_SSL: booleanString.default(true),\n /** The time to wait for a response, in milliseconds. The default is 30000. */\n REQUEST_TIMEOUT_MS: positiveInt.default(30_000),\n /** Whether to run tests that delete or change shared data. The default is `false`. */\n RUN_DESTRUCTIVE_TESTS: booleanString.default(false),\n /** Whether to leave out tests that fail because of a known platform defect. The default is `false`. */\n SKIP_PLATFORM_DEFECTS: booleanString.default(false),\n /** The number of workers that run API tests, such as REST and GraphQL tests. The default is 4. */\n API_WORKERS: positiveInt.default(4),\n /** The number of workers that run end-to-end browser tests. The default is 3. */\n E2E_WORKERS: positiveInt.default(3),\n});\n\n/** The environment variables parsed by {@link envSchema}. */\nexport type Env = output<typeof envSchema>;\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the message of a thrown value.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* throw new Error(`Reading the modules failed: ${errorMessage(error)}`, { cause: error });
|
|
6
|
+
*
|
|
7
|
+
* @param error - The thrown value: an `Error`, or anything else.
|
|
8
|
+
* @returns The message of an `Error`, or the value as a string.
|
|
9
|
+
*/
|
|
10
|
+
export declare function errorMessage(error: unknown): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the message of a thrown value.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* throw new Error(`Reading the modules failed: ${errorMessage(error)}`, { cause: error });
|
|
6
|
+
*
|
|
7
|
+
* @param error - The thrown value: an `Error`, or anything else.
|
|
8
|
+
* @returns The message of an `Error`, or the value as a string.
|
|
9
|
+
*/
|
|
10
|
+
export function errorMessage(error) {
|
|
11
|
+
return error instanceof Error ? error.message : String(error);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=error-message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-message.js","sourceRoot":"","sources":["../../src/core/error-message.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC","sourcesContent":["/**\n * Returns the message of a thrown value.\n *\n * @example\n * throw new Error(`Reading the modules failed: ${errorMessage(error)}`, { cause: error });\n *\n * @param error - The thrown value: an `Error`, or anything else.\n * @returns The message of an `Error`, or the value as a string.\n */\nexport function errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type { DefaultReporterOptions } from "./default-reporters.ts";
|
|
2
|
+
export type { DefaultUse, DefaultUseOptions } from "./default-use.ts";
|
|
3
|
+
export type { Env } from "./env.ts";
|
|
4
|
+
export type { DefaultRunOptions } from "./run-options.ts";
|
|
5
|
+
export type { SecretsAllowed } from "./secret.ts";
|
|
6
|
+
export type { UrlPath } from "./url-path.ts";
|
|
7
|
+
export { defaultReporters } from "./default-reporters.ts";
|
|
8
|
+
export { defaultUse } from "./default-use.ts";
|
|
9
|
+
export { envSchema } from "./env.ts";
|
|
10
|
+
export { errorMessage } from "./error-message.ts";
|
|
11
|
+
export { isCi } from "./is-ci.ts";
|
|
12
|
+
export { parseEnv } from "./parse-env.ts";
|
|
13
|
+
export { apiProject, e2eProject } from "./projects.ts";
|
|
14
|
+
export { DESTRUCTIVE_TAG, defaultRunOptions, PLATFORM_DEFECT_TAG } from "./run-options.ts";
|
|
15
|
+
export { MASKED, maskSecrets, revealedFields, revealedJson, SECRET_MIN_LENGTH, Secret } from "./secret.ts";
|
|
16
|
+
export { absoluteUrl, booleanString, nonBlankString, originUrl, positiveInt, secretString, } from "./string-schemas.ts";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { defaultReporters } from "./default-reporters.js";
|
|
2
|
+
export { defaultUse } from "./default-use.js";
|
|
3
|
+
export { envSchema } from "./env.js";
|
|
4
|
+
export { errorMessage } from "./error-message.js";
|
|
5
|
+
export { isCi } from "./is-ci.js";
|
|
6
|
+
export { parseEnv } from "./parse-env.js";
|
|
7
|
+
export { apiProject, e2eProject } from "./projects.js";
|
|
8
|
+
export { DESTRUCTIVE_TAG, defaultRunOptions, PLATFORM_DEFECT_TAG } from "./run-options.js";
|
|
9
|
+
export { MASKED, maskSecrets, revealedFields, revealedJson, SECRET_MIN_LENGTH, Secret } from "./secret.js";
|
|
10
|
+
export { absoluteUrl, booleanString, nonBlankString, originUrl, positiveInt, secretString, } from "./string-schemas.js";
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC3F,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC3G,OAAO,EACL,WAAW,EACX,aAAa,EACb,cAAc,EACd,SAAS,EACT,WAAW,EACX,YAAY,GACb,MAAM,qBAAqB,CAAC","sourcesContent":["export type { DefaultReporterOptions } from \"./default-reporters.ts\";\nexport type { DefaultUse, DefaultUseOptions } from \"./default-use.ts\";\nexport type { Env } from \"./env.ts\";\nexport type { DefaultRunOptions } from \"./run-options.ts\";\nexport type { SecretsAllowed } from \"./secret.ts\";\nexport type { UrlPath } from \"./url-path.ts\";\n\nexport { defaultReporters } from \"./default-reporters.ts\";\nexport { defaultUse } from \"./default-use.ts\";\nexport { envSchema } from \"./env.ts\";\nexport { errorMessage } from \"./error-message.ts\";\nexport { isCi } from \"./is-ci.ts\";\nexport { parseEnv } from \"./parse-env.ts\";\nexport { apiProject, e2eProject } from \"./projects.ts\";\nexport { DESTRUCTIVE_TAG, defaultRunOptions, PLATFORM_DEFECT_TAG } from \"./run-options.ts\";\nexport { MASKED, maskSecrets, revealedFields, revealedJson, SECRET_MIN_LENGTH, Secret } from \"./secret.ts\";\nexport {\n absoluteUrl,\n booleanString,\n nonBlankString,\n originUrl,\n positiveInt,\n secretString,\n} from \"./string-schemas.ts\";\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determines whether the process runs on a continuous integration service.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* CI services set the `CI` variable, such as `CI=true` on GitHub Actions. An empty value, `false` and `0` do not count,
|
|
6
|
+
* so `CI=false` turns CI behavior off on a developer machine.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* forbidOnly: isCi(),
|
|
10
|
+
*
|
|
11
|
+
* @param source - The variables to read. The default is `process.env`.
|
|
12
|
+
* @returns `true` if `CI` is set to a value other than empty, `false` or `0`; otherwise, `false`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function isCi(source?: NodeJS.ProcessEnv): boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determines whether the process runs on a continuous integration service.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* CI services set the `CI` variable, such as `CI=true` on GitHub Actions. An empty value, `false` and `0` do not count,
|
|
6
|
+
* so `CI=false` turns CI behavior off on a developer machine.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* forbidOnly: isCi(),
|
|
10
|
+
*
|
|
11
|
+
* @param source - The variables to read. The default is `process.env`.
|
|
12
|
+
* @returns `true` if `CI` is set to a value other than empty, `false` or `0`; otherwise, `false`.
|
|
13
|
+
*/
|
|
14
|
+
export function isCi(source = process.env) {
|
|
15
|
+
const value = source["CI"]?.trim().toLowerCase();
|
|
16
|
+
return value !== undefined && value !== "" && value !== "false" && value !== "0";
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=is-ci.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-ci.js","sourceRoot":"","sources":["../../src/core/is-ci.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,IAAI,CAAC,MAAM,GAAsB,OAAO,CAAC,GAAG;IAC1D,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACjD,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE,IAAI,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,GAAG,CAAC;AACnF,CAAC","sourcesContent":["/**\n * Determines whether the process runs on a continuous integration service.\n *\n * @remarks\n * CI services set the `CI` variable, such as `CI=true` on GitHub Actions. An empty value, `false` and `0` do not count,\n * so `CI=false` turns CI behavior off on a developer machine.\n *\n * @example\n * forbidOnly: isCi(),\n *\n * @param source - The variables to read. The default is `process.env`.\n * @returns `true` if `CI` is set to a value other than empty, `false` or `0`; otherwise, `false`.\n */\nexport function isCi(source: NodeJS.ProcessEnv = process.env): boolean {\n const value = source[\"CI\"]?.trim().toLowerCase();\n return value !== undefined && value !== \"\" && value !== \"false\" && value !== \"0\";\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { output, ZodType } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Parses environment variables with a schema.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* An empty variable counts as unset, so the schema's default applies to it.
|
|
7
|
+
*
|
|
8
|
+
* @param schema - The schema that describes the variables.
|
|
9
|
+
* @param source - The variables to parse. The default is `process.env`.
|
|
10
|
+
* @returns The parsed variables.
|
|
11
|
+
* @throws {Error} One or more variables are invalid. The message lists each one and does not contain the values.
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseEnv<S extends ZodType>(schema: S, source?: NodeJS.ProcessEnv): output<S>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { prettifyError } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Parses environment variables with a schema.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* An empty variable counts as unset, so the schema's default applies to it.
|
|
7
|
+
*
|
|
8
|
+
* @param schema - The schema that describes the variables.
|
|
9
|
+
* @param source - The variables to parse. The default is `process.env`.
|
|
10
|
+
* @returns The parsed variables.
|
|
11
|
+
* @throws {Error} One or more variables are invalid. The message lists each one and does not contain the values.
|
|
12
|
+
*/
|
|
13
|
+
export function parseEnv(schema, source = process.env) {
|
|
14
|
+
const present = Object.fromEntries(Object.entries(source).filter(([, value]) => value !== undefined && value !== ""));
|
|
15
|
+
const result = schema.safeParse(present);
|
|
16
|
+
if (!result.success) {
|
|
17
|
+
throw new Error(`Invalid environment variables:\n${prettifyError(result.error)}`);
|
|
18
|
+
}
|
|
19
|
+
return result.data;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=parse-env.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-env.js","sourceRoot":"","sources":["../../src/core/parse-env.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,QAAQ,CAAoB,MAAS,EAAE,MAAM,GAAsB,OAAO,CAAC,GAAG;IAC5F,MAAM,OAAO,GAAG,MAAM,CAAC,WAAW,CAChC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAA+B,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,EAAE,CAAC,CAChH,CAAC;IACF,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACzC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,mCAAmC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACpF,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC","sourcesContent":["import type { output, ZodType } from \"zod\";\n\nimport { prettifyError } from \"zod\";\n\n/**\n * Parses environment variables with a schema.\n *\n * @remarks\n * An empty variable counts as unset, so the schema's default applies to it.\n *\n * @param schema - The schema that describes the variables.\n * @param source - The variables to parse. The default is `process.env`.\n * @returns The parsed variables.\n * @throws {Error} One or more variables are invalid. The message lists each one and does not contain the values.\n */\nexport function parseEnv<S extends ZodType>(schema: S, source: NodeJS.ProcessEnv = process.env): output<S> {\n const present = Object.fromEntries(\n Object.entries(source).filter(([, value]: [string, string | undefined]) => value !== undefined && value !== \"\"),\n );\n const result = schema.safeParse(present);\n if (!result.success) {\n throw new Error(`Invalid environment variables:\\n${prettifyError(result.error)}`);\n }\n return result.data;\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Project } from "@playwright/test";
|
|
2
|
+
import type { Env } from "./env.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Returns a project of API tests, such as REST and GraphQL tests, limited to `API_WORKERS` workers.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* apiProject(env, { name: "rest", testDir: "tests/rest", dependencies: ["seed"] }),
|
|
8
|
+
*
|
|
9
|
+
* @param env - The parsed environment variables.
|
|
10
|
+
* @param project - The project. Its own `workers` replaces the limit.
|
|
11
|
+
* @returns The project with its worker limit.
|
|
12
|
+
*/
|
|
13
|
+
export declare function apiProject<TTestArgs, TWorkerArgs>(env: Env, project: Project<TTestArgs, TWorkerArgs>): Project<TTestArgs, TWorkerArgs>;
|
|
14
|
+
/**
|
|
15
|
+
* Returns a project of end-to-end browser tests, limited to `E2E_WORKERS` workers.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* e2eProject(env, { name: "frontend", testDir: "tests/e2e/frontend", use: { ...devices["Desktop Chrome"] } }),
|
|
19
|
+
*
|
|
20
|
+
* @param env - The parsed environment variables.
|
|
21
|
+
* @param project - The project. Its own `workers` replaces the limit.
|
|
22
|
+
* @returns The project with its worker limit.
|
|
23
|
+
*/
|
|
24
|
+
export declare function e2eProject<TTestArgs, TWorkerArgs>(env: Env, project: Project<TTestArgs, TWorkerArgs>): Project<TTestArgs, TWorkerArgs>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a project of API tests, such as REST and GraphQL tests, limited to `API_WORKERS` workers.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* apiProject(env, { name: "rest", testDir: "tests/rest", dependencies: ["seed"] }),
|
|
6
|
+
*
|
|
7
|
+
* @param env - The parsed environment variables.
|
|
8
|
+
* @param project - The project. Its own `workers` replaces the limit.
|
|
9
|
+
* @returns The project with its worker limit.
|
|
10
|
+
*/
|
|
11
|
+
export function apiProject(env, project) {
|
|
12
|
+
return {
|
|
13
|
+
workers: env.API_WORKERS,
|
|
14
|
+
...project,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Returns a project of end-to-end browser tests, limited to `E2E_WORKERS` workers.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* e2eProject(env, { name: "frontend", testDir: "tests/e2e/frontend", use: { ...devices["Desktop Chrome"] } }),
|
|
22
|
+
*
|
|
23
|
+
* @param env - The parsed environment variables.
|
|
24
|
+
* @param project - The project. Its own `workers` replaces the limit.
|
|
25
|
+
* @returns The project with its worker limit.
|
|
26
|
+
*/
|
|
27
|
+
export function e2eProject(env, project) {
|
|
28
|
+
return {
|
|
29
|
+
workers: env.E2E_WORKERS,
|
|
30
|
+
...project,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=projects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projects.js","sourceRoot":"","sources":["../../src/core/projects.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,MAAM,UAAU,UAAU,CACxB,GAAQ,EACR,OAAwC;IAExC,OAAO;QACL,OAAO,EAAE,GAAG,CAAC,WAAW;QACxB,GAAG,OAAO;KACX,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,UAAU,CACxB,GAAQ,EACR,OAAwC;IAExC,OAAO;QACL,OAAO,EAAE,GAAG,CAAC,WAAW;QACxB,GAAG,OAAO;KACX,CAAC;AACJ,CAAC","sourcesContent":["import type { Project } from \"@playwright/test\";\nimport type { Env } from \"./env.ts\";\n\n/**\n * Returns a project of API tests, such as REST and GraphQL tests, limited to `API_WORKERS` workers.\n *\n * @example\n * apiProject(env, { name: \"rest\", testDir: \"tests/rest\", dependencies: [\"seed\"] }),\n *\n * @param env - The parsed environment variables.\n * @param project - The project. Its own `workers` replaces the limit.\n * @returns The project with its worker limit.\n */\nexport function apiProject<TTestArgs, TWorkerArgs>(\n env: Env,\n project: Project<TTestArgs, TWorkerArgs>,\n): Project<TTestArgs, TWorkerArgs> {\n return {\n workers: env.API_WORKERS,\n ...project,\n };\n}\n\n/**\n * Returns a project of end-to-end browser tests, limited to `E2E_WORKERS` workers.\n *\n * @example\n * e2eProject(env, { name: \"frontend\", testDir: \"tests/e2e/frontend\", use: { ...devices[\"Desktop Chrome\"] } }),\n *\n * @param env - The parsed environment variables.\n * @param project - The project. Its own `workers` replaces the limit.\n * @returns The project with its worker limit.\n */\nexport function e2eProject<TTestArgs, TWorkerArgs>(\n env: Env,\n project: Project<TTestArgs, TWorkerArgs>,\n): Project<TTestArgs, TWorkerArgs> {\n return {\n workers: env.E2E_WORKERS,\n ...project,\n };\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { PlaywrightTestConfig } from "@playwright/test";
|
|
2
|
+
import type { Env } from "./env.ts";
|
|
3
|
+
/** The tag of tests that delete or change shared data. They run only when `RUN_DESTRUCTIVE_TESTS` is on. */
|
|
4
|
+
export declare const DESTRUCTIVE_TAG = "@destructive";
|
|
5
|
+
/**
|
|
6
|
+
* The tag of tests that fail because of a known platform defect. They are left out when `SKIP_PLATFORM_DEFECTS` is on,
|
|
7
|
+
* so that the CI of the platform and its modules is not red for a defect that a ticket already tracks.
|
|
8
|
+
*/
|
|
9
|
+
export declare const PLATFORM_DEFECT_TAG = "@platform-defect";
|
|
10
|
+
/** The run options of a test suite, as {@link defaultRunOptions} returns them. */
|
|
11
|
+
export type DefaultRunOptions = Pick<PlaywrightTestConfig, "forbidOnly" | "retries" | "workers" | "grepInvert">;
|
|
12
|
+
/**
|
|
13
|
+
* Returns the run options of a test suite: no retries, no `test.only` on CI, the workers of the larger worker budget,
|
|
14
|
+
* and destructive tests and known platform defects left out as the environment says.
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* - Failed tests are not retried, so a flaky test fails and is fixed rather than hidden.
|
|
18
|
+
* - `workers` is the larger of `API_WORKERS` and `E2E_WORKERS`. Each project stays within its own limit, see
|
|
19
|
+
* {@link apiProject} and {@link e2eProject}, and API and browser projects that run at the same time share these
|
|
20
|
+
* workers instead of adding up.
|
|
21
|
+
* - Tests tagged with {@link DESTRUCTIVE_TAG} are left out unless `RUN_DESTRUCTIVE_TESTS` is on, and tests tagged with
|
|
22
|
+
* {@link PLATFORM_DEFECT_TAG} when `SKIP_PLATFORM_DEFECTS` is on. A project that sets its own `grepInvert` replaces
|
|
23
|
+
* this filter.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* export default defineConfig({ ...defaultRunOptions(env), projects: [] });
|
|
27
|
+
*
|
|
28
|
+
* @param env - The parsed environment variables.
|
|
29
|
+
* @returns The options, to spread into the Playwright config.
|
|
30
|
+
*/
|
|
31
|
+
export declare function defaultRunOptions(env: Env): DefaultRunOptions;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { isCi } from "./is-ci.js";
|
|
2
|
+
/** The tag of tests that delete or change shared data. They run only when `RUN_DESTRUCTIVE_TESTS` is on. */
|
|
3
|
+
export const DESTRUCTIVE_TAG = "@destructive";
|
|
4
|
+
/**
|
|
5
|
+
* The tag of tests that fail because of a known platform defect. They are left out when `SKIP_PLATFORM_DEFECTS` is on,
|
|
6
|
+
* so that the CI of the platform and its modules is not red for a defect that a ticket already tracks.
|
|
7
|
+
*/
|
|
8
|
+
export const PLATFORM_DEFECT_TAG = "@platform-defect";
|
|
9
|
+
/**
|
|
10
|
+
* Returns the run options of a test suite: no retries, no `test.only` on CI, the workers of the larger worker budget,
|
|
11
|
+
* and destructive tests and known platform defects left out as the environment says.
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* - Failed tests are not retried, so a flaky test fails and is fixed rather than hidden.
|
|
15
|
+
* - `workers` is the larger of `API_WORKERS` and `E2E_WORKERS`. Each project stays within its own limit, see
|
|
16
|
+
* {@link apiProject} and {@link e2eProject}, and API and browser projects that run at the same time share these
|
|
17
|
+
* workers instead of adding up.
|
|
18
|
+
* - Tests tagged with {@link DESTRUCTIVE_TAG} are left out unless `RUN_DESTRUCTIVE_TESTS` is on, and tests tagged with
|
|
19
|
+
* {@link PLATFORM_DEFECT_TAG} when `SKIP_PLATFORM_DEFECTS` is on. A project that sets its own `grepInvert` replaces
|
|
20
|
+
* this filter.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* export default defineConfig({ ...defaultRunOptions(env), projects: [] });
|
|
24
|
+
*
|
|
25
|
+
* @param env - The parsed environment variables.
|
|
26
|
+
* @returns The options, to spread into the Playwright config.
|
|
27
|
+
*/
|
|
28
|
+
export function defaultRunOptions(env) {
|
|
29
|
+
return {
|
|
30
|
+
forbidOnly: isCi(),
|
|
31
|
+
retries: 0,
|
|
32
|
+
workers: Math.max(env.API_WORKERS, env.E2E_WORKERS),
|
|
33
|
+
...leftOut(env),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function leftOut(env) {
|
|
37
|
+
const tags = [
|
|
38
|
+
...(env.RUN_DESTRUCTIVE_TESTS ? [] : [DESTRUCTIVE_TAG]),
|
|
39
|
+
...(env.SKIP_PLATFORM_DEFECTS ? [PLATFORM_DEFECT_TAG] : []),
|
|
40
|
+
];
|
|
41
|
+
return tags.length === 0 ? {} : { grepInvert: new RegExp(`(${tags.join("|")})(?=\\s|$)`) };
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=run-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-options.js","sourceRoot":"","sources":["../../src/core/run-options.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,4GAA4G;AAC5G,MAAM,CAAC,MAAM,eAAe,GAAG,cAAc,CAAC;AAE9C;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,kBAAkB,CAAC;AAKtD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAQ;IACxC,OAAO;QACL,UAAU,EAAE,IAAI,EAAE;QAClB,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,GAAG,CAAC,WAAW,CAAC;QACnD,GAAG,OAAO,CAAC,GAAG,CAAC;KAChB,CAAC;AACJ,CAAC;AAED,SAAS,OAAO,CAAC,GAAQ;IACvB,MAAM,IAAI,GAAG;QACX,GAAG,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;QACvD,GAAG,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5D,CAAC;IACF,OAAO,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,MAAM,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;AAC7F,CAAC","sourcesContent":["import type { PlaywrightTestConfig } from \"@playwright/test\";\nimport type { Env } from \"./env.ts\";\n\nimport { isCi } from \"./is-ci.ts\";\n\n/** The tag of tests that delete or change shared data. They run only when `RUN_DESTRUCTIVE_TESTS` is on. */\nexport const DESTRUCTIVE_TAG = \"@destructive\";\n\n/**\n * The tag of tests that fail because of a known platform defect. They are left out when `SKIP_PLATFORM_DEFECTS` is on,\n * so that the CI of the platform and its modules is not red for a defect that a ticket already tracks.\n */\nexport const PLATFORM_DEFECT_TAG = \"@platform-defect\";\n\n/** The run options of a test suite, as {@link defaultRunOptions} returns them. */\nexport type DefaultRunOptions = Pick<PlaywrightTestConfig, \"forbidOnly\" | \"retries\" | \"workers\" | \"grepInvert\">;\n\n/**\n * Returns the run options of a test suite: no retries, no `test.only` on CI, the workers of the larger worker budget,\n * and destructive tests and known platform defects left out as the environment says.\n *\n * @remarks\n * - Failed tests are not retried, so a flaky test fails and is fixed rather than hidden.\n * - `workers` is the larger of `API_WORKERS` and `E2E_WORKERS`. Each project stays within its own limit, see\n * {@link apiProject} and {@link e2eProject}, and API and browser projects that run at the same time share these\n * workers instead of adding up.\n * - Tests tagged with {@link DESTRUCTIVE_TAG} are left out unless `RUN_DESTRUCTIVE_TESTS` is on, and tests tagged with\n * {@link PLATFORM_DEFECT_TAG} when `SKIP_PLATFORM_DEFECTS` is on. A project that sets its own `grepInvert` replaces\n * this filter.\n *\n * @example\n * export default defineConfig({ ...defaultRunOptions(env), projects: [] });\n *\n * @param env - The parsed environment variables.\n * @returns The options, to spread into the Playwright config.\n */\nexport function defaultRunOptions(env: Env): DefaultRunOptions {\n return {\n forbidOnly: isCi(),\n retries: 0,\n workers: Math.max(env.API_WORKERS, env.E2E_WORKERS),\n ...leftOut(env),\n };\n}\n\nfunction leftOut(env: Env): Pick<DefaultRunOptions, \"grepInvert\"> {\n const tags = [\n ...(env.RUN_DESTRUCTIVE_TESTS ? [] : [DESTRUCTIVE_TAG]),\n ...(env.SKIP_PLATFORM_DEFECTS ? [PLATFORM_DEFECT_TAG] : []),\n ];\n return tags.length === 0 ? {} : { grepInvert: new RegExp(`(${tags.join(\"|\")})(?=\\\\s|$)`) };\n}\n"]}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { inspect } from "node:util";
|
|
2
|
+
/** The text that replaces a secret value in string conversion, JSON serialization, console output and masked text. */
|
|
3
|
+
export declare const MASKED = "[SECRET]";
|
|
4
|
+
/** The minimum length of a secret value. A shorter value cannot be masked without also masking ordinary text. */
|
|
5
|
+
export declare const SECRET_MIN_LENGTH = 4;
|
|
6
|
+
/**
|
|
7
|
+
* A type in which every string can also be a {@link Secret}. It describes plain JSON values that are revealed only when
|
|
8
|
+
* sent, such as request bodies and GraphQL variables.
|
|
9
|
+
*/
|
|
10
|
+
export type SecretsAllowed<T> = T extends string ? T | Secret : T extends readonly (infer Item)[] ? readonly SecretsAllowed<Item>[] : T extends object ? {
|
|
11
|
+
readonly [K in keyof T]: SecretsAllowed<T[K]>;
|
|
12
|
+
} : T;
|
|
13
|
+
/**
|
|
14
|
+
* Represents a password, token or key whose value never appears in output. String conversion, JSON serialization and
|
|
15
|
+
* console output produce {@link MASKED}.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* Each value created by {@link Secret.of} is registered for {@link maskSecrets} for the lifetime of the process.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* const password = Secret.of("Password1!");
|
|
22
|
+
* `${password}`; // "[SECRET]"
|
|
23
|
+
* JSON.stringify({ password }); // '{"password":"[SECRET]"}'
|
|
24
|
+
* password.reveal(); // "Password1!"
|
|
25
|
+
* maskSecrets("password=Password1%21"); // "password=[SECRET]"
|
|
26
|
+
*/
|
|
27
|
+
export declare class Secret {
|
|
28
|
+
#private;
|
|
29
|
+
private constructor();
|
|
30
|
+
/**
|
|
31
|
+
* Creates a secret and registers its value for {@link maskSecrets} in plain, URI-encoded, form-encoded and
|
|
32
|
+
* JSON-escaped forms.
|
|
33
|
+
*
|
|
34
|
+
* @param value - The plain value.
|
|
35
|
+
* @returns The secret that holds the value.
|
|
36
|
+
* @throws {RangeError} The value is shorter than {@link SECRET_MIN_LENGTH}. The message does not contain the value.
|
|
37
|
+
*/
|
|
38
|
+
static of(value: string): Secret;
|
|
39
|
+
/**
|
|
40
|
+
* Determines whether this secret and another secret hold the same value, without revealing either value.
|
|
41
|
+
*
|
|
42
|
+
* @param other - The secret to compare with.
|
|
43
|
+
* @returns `true` if the values are equal; otherwise, `false`.
|
|
44
|
+
*/
|
|
45
|
+
equals(other: Secret): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Returns a secret that holds a prefix followed by this value, such as the value of an `Authorization` header.
|
|
48
|
+
*
|
|
49
|
+
* @remarks
|
|
50
|
+
* The new value is not registered for {@link maskSecrets}, because this value already is, and it is masked as a whole
|
|
51
|
+
* token when the prefix ends with a character other than a letter or a digit, such as a space.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* accessToken.withPrefix("Bearer "); // the secret "Bearer <token>"
|
|
55
|
+
*
|
|
56
|
+
* @param prefix - The text before the value, such as `Bearer `.
|
|
57
|
+
* @returns The new secret.
|
|
58
|
+
*/
|
|
59
|
+
withPrefix(prefix: string): Secret;
|
|
60
|
+
/**
|
|
61
|
+
* Returns the plain value.
|
|
62
|
+
*
|
|
63
|
+
* @remarks
|
|
64
|
+
* Call this method only where the value is sent or stored. Keep the result out of messages, logs and assertions.
|
|
65
|
+
*/
|
|
66
|
+
reveal(): string;
|
|
67
|
+
/** Returns {@link MASKED} instead of the value. */
|
|
68
|
+
toString(): string;
|
|
69
|
+
/** Returns {@link MASKED} instead of the value. It is called during JSON serialization. */
|
|
70
|
+
toJSON(): string;
|
|
71
|
+
/** Returns {@link MASKED} instead of the value. It is called when the secret is printed to the console. */
|
|
72
|
+
[inspect.custom](): string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Replaces each registered secret value in a text with {@link MASKED}.
|
|
76
|
+
*
|
|
77
|
+
* @remarks
|
|
78
|
+
* A value is replaced only where it stands as a whole token: `admin` is masked in `password=admin`, but not in
|
|
79
|
+
* `administrator`. Use this function for error messages and logs that can contain requests or responses.
|
|
80
|
+
*
|
|
81
|
+
* @param text - The text to mask.
|
|
82
|
+
* @returns The text in which each registered secret value is replaced with {@link MASKED}.
|
|
83
|
+
*/
|
|
84
|
+
export declare function maskSecrets(text: string): string;
|
|
85
|
+
/**
|
|
86
|
+
* Returns a copy of fields such as headers or form values with each {@link Secret} replaced by its value.
|
|
87
|
+
*
|
|
88
|
+
* @remarks
|
|
89
|
+
* Call this function only where the values are sent. Keep the result out of messages, logs and assertions.
|
|
90
|
+
*
|
|
91
|
+
* @param fields - The fields to reveal.
|
|
92
|
+
* @returns A copy of the fields in which each {@link Secret} is replaced by its value.
|
|
93
|
+
*/
|
|
94
|
+
export declare function revealedFields<V>(fields: Readonly<Record<string, V | Secret>>): Record<string, V | string>;
|
|
95
|
+
/**
|
|
96
|
+
* Serializes a value to JSON with each {@link Secret}, at any depth, written as its value.
|
|
97
|
+
*
|
|
98
|
+
* @remarks
|
|
99
|
+
* Call this function only where the JSON is sent. Keep the result out of messages, logs and assertions.
|
|
100
|
+
*
|
|
101
|
+
* @param value - The value to serialize.
|
|
102
|
+
* @returns The JSON text.
|
|
103
|
+
* @throws {TypeError} The value is `undefined`, a function or a symbol.
|
|
104
|
+
*/
|
|
105
|
+
export declare function revealedJson(value: unknown): string;
|