@piwitests/reporter 0.64.0 → 0.66.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.
@@ -16,8 +16,8 @@ import { TestInfo } from '@playwright/test';
16
16
  interface InspectionGate {
17
17
  /** Raw `PIWI_INSPECT_ON_FAIL` env value — only the string `'true'` enables. */
18
18
  enabled: string | undefined;
19
- /** Raw `CI` env value. Anything except unset/empty/`'false'` counts as CI. */
20
- ci: string | undefined;
19
+ /** Whether the run is a CI job, as `detectCi` reads the environment. */
20
+ ci: boolean;
21
21
  /** `testInfo.status` at teardown. */
22
22
  status: string | undefined;
23
23
  /** `testInfo.expectedStatus` — an expected failure (test.fail()) never pauses. */
@@ -29,8 +29,6 @@ interface InspectionGate {
29
29
  /** Configured retry count for the project (`testInfo.project.retries`). */
30
30
  retries: number;
31
31
  }
32
- /** True when this raw `CI` env value counts as "running under CI". */
33
- declare function isCi(ci: string | undefined): boolean;
34
32
  /** Decide whether the failing page should be handed to the Inspector. */
35
33
  declare function shouldInspectOnFailure(gate: InspectionGate): boolean;
36
34
  /**
@@ -49,4 +47,4 @@ declare function environmentalSkipReason(gate: InspectionGate): string | null;
49
47
  */
50
48
  declare function inspectionGateFromTestInfo(testInfo: TestInfo, enabled?: string | undefined): InspectionGate;
51
49
 
52
- export { type InspectionGate, environmentalSkipReason, inspectionGateFromTestInfo, isCi, shouldInspectOnFailure };
50
+ export { type InspectionGate, environmentalSkipReason, inspectionGateFromTestInfo, shouldInspectOnFailure };
@@ -22,16 +22,21 @@ var inspect_on_failure_exports = {};
22
22
  __export(inspect_on_failure_exports, {
23
23
  environmentalSkipReason: () => environmentalSkipReason,
24
24
  inspectionGateFromTestInfo: () => inspectionGateFromTestInfo,
25
- isCi: () => isCi,
26
25
  shouldInspectOnFailure: () => shouldInspectOnFailure
27
26
  });
28
27
  module.exports = __toCommonJS(inspect_on_failure_exports);
29
- function isCi(ci) {
30
- return ci !== void 0 && ci !== "" && ci !== "false";
28
+
29
+ // src/internal/support/ci.ts
30
+ function detectCi(env) {
31
+ return Boolean(
32
+ env.JENKINS_URL || env.GITHUB_ACTIONS || env.GITLAB_CI || env.CIRCLECI || env.TRAVIS || env.TF_BUILD || env.BITBUCKET_BUILD_NUMBER || env.TEAMCITY_VERSION || env.CODEBUILD_BUILD_ID || env.bamboo_buildKey || env.CI && env.CI.toLowerCase() !== "false" && env.CI !== "0"
33
+ );
31
34
  }
35
+
36
+ // src/internal/capture/inspect-on-failure.ts
32
37
  function shouldInspectOnFailure(gate) {
33
38
  if (gate.enabled !== "true") return false;
34
- if (isCi(gate.ci)) return false;
39
+ if (gate.ci) return false;
35
40
  if (gate.headless !== false) return false;
36
41
  if (gate.status !== "failed" && gate.status !== "timedOut") return false;
37
42
  if (gate.status === gate.expectedStatus) return false;
@@ -41,7 +46,7 @@ function environmentalSkipReason(gate) {
41
46
  if (gate.enabled !== "true") return null;
42
47
  if (gate.status !== "failed" && gate.status !== "timedOut") return null;
43
48
  if (gate.status === gate.expectedStatus) return null;
44
- if (isCi(gate.ci)) return "running under CI \u2014 this is a headed, local-only feature";
49
+ if (gate.ci) return "running under CI \u2014 this is a headed, local-only feature";
45
50
  if (gate.headless !== false) {
46
51
  return "the browser is headless \u2014 re-run with --headed (or set use: { headless: false })";
47
52
  }
@@ -51,7 +56,7 @@ function inspectionGateFromTestInfo(testInfo, enabled = process.env.PIWI_INSPECT
51
56
  const use = testInfo.project?.use ?? {};
52
57
  return {
53
58
  enabled,
54
- ci: process.env.CI,
59
+ ci: detectCi(process.env),
55
60
  status: testInfo.status,
56
61
  expectedStatus: testInfo.expectedStatus,
57
62
  headless: use.headless,
@@ -63,6 +68,5 @@ function inspectionGateFromTestInfo(testInfo, enabled = process.env.PIWI_INSPECT
63
68
  0 && (module.exports = {
64
69
  environmentalSkipReason,
65
70
  inspectionGateFromTestInfo,
66
- isCi,
67
71
  shouldInspectOnFailure
68
72
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@piwitests/reporter",
3
- "version": "0.64.0",
3
+ "version": "0.66.0",
4
4
  "description": "Playwright reporter that streams results, traces and HTML reports to a Piwi Dashboard instance",
5
5
  "url": "https://github.com/PiwiTests/piwi",
6
6
  "homepage": "https://piwitests.dev",
@@ -28,7 +28,7 @@ npx @piwitests/reporter init --server-url <dashboard-url> --project <name> --jso
28
28
  ```
29
29
 
30
30
  - Preview first with `--dry-run` if you want to see the plan before anything is written.
31
- - `--api-key <key>` also writes the key and the URL into `.env` and adds `.env` to `.gitignore`.
31
+ - `--api-key <key>` also writes the key and the URL into `.env` and adds `.env` to `.gitignore`. When git tracks `.env`, or cannot say whether it does, or `.env` is a link, it writes no key and reports the `env` step as `manual`: never put the key into that file yourself. Have the user set `PIWI_API_KEY` in the environment instead (in CI, as a secret): that finishes the step, and `init` run again without `--api-key` leaves nothing `manual` for it.
32
32
  - `--skills none` installs no skills; `--skills-dir <path>` installs them where your agent reads skills from.
33
33
  - `--json` prints a `steps[]` array and the `nextSteps` to tell the user. Read it. Each step has a `status`:
34
34
  - `created` / `updated` / `already` — done, nothing more to do.
@@ -38,7 +38,7 @@ npx @piwitests/reporter init --server-url <dashboard-url> --project <name> --jso
38
38
 
39
39
  ### Finishing `manual` steps
40
40
 
41
- - **config** marked `manual`: the config is not a plain `export default defineConfig(...)`. Add `import { wrapConfig } from '@piwitests/reporter'` and wrap the exported config: `export default wrapConfig(defineConfig({ ... }), { serverUrl, projectName })`.
41
+ - **config** marked `manual`: the config is not a plain `export default defineConfig(...)`. Add `import { wrapConfig } from '@piwitests/reporter'` and wrap the exported config: `export default wrapConfig(defineConfig({ ... }), { serverUrl, projectName })`. At a workspace root where several packages hold a Playwright config, the `detail` names them instead: run `init` again with `--cwd <package>` for each package to wire.
42
42
  - **fixtures** marked `manual`: a fixtures file already exists. Merge Piwi in: `import { piwiFixtures } from '@piwitests/reporter'` and compose them into the existing `base.extend(...)` (or use `extendPiwiFixtures(base)`).
43
43
 
44
44
  ### Rewire the specs to the fixtures
@@ -53,7 +53,7 @@ change it to import from the fixtures file instead, e.g. `import { test, expect
53
53
 
54
54
  ## Authentication
55
55
 
56
- If the dashboard has auth enabled, runs need an API key. Have the user create one in the dashboard (**Settings → Account → API keys**; keys start with `pd_`), then put it in `.env` as `PIWI_API_KEY=pd_...` (or re-run `init` with `--api-key`) and make sure `.env` is git-ignored. The reporter reads `PIWI_DASHBOARD_URL`, `PIWI_API_KEY` and `PIWI_PROJECT_NAME` from the `.env` next to `playwright.config`, so the config needs no dotenv loading; a variable set in the environment wins over the file. Never hardcode a key into `playwright.config.ts` or commit it. In CI, where `.env` is not checked out, pass it as a secret (`PIWI_API_KEY`).
56
+ If the dashboard has auth enabled, runs need an API key. Have the user create one in the dashboard (**Settings → Account → API keys**; keys start with `pd_`), then put it in `.env` as `PIWI_API_KEY=pd_...` (or re-run `init` with `--api-key`) and make sure `.env` is git-ignored and not tracked (`git rm --cached .env` untracks it). The reporter reads `PIWI_DASHBOARD_URL`, `PIWI_API_KEY` and `PIWI_PROJECT_NAME` from the `.env` next to `playwright.config`, so the config needs no dotenv loading; a variable set in the environment wins over the file. Never hardcode a key into `playwright.config.ts` or commit it. In CI, where `.env` is not checked out, pass it as a secret (`PIWI_API_KEY`).
57
57
 
58
58
  ## Verify it worked
59
59