playwright-testchimp 0.1.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,26 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.TestChimpApiClient = exports.TestChimpReporter = void 0;
18
+ var testchimp_reporter_1 = require("./testchimp-reporter");
19
+ Object.defineProperty(exports, "TestChimpReporter", { enumerable: true, get: function () { return testchimp_reporter_1.TestChimpReporter; } });
20
+ var api_client_1 = require("./api-client");
21
+ Object.defineProperty(exports, "TestChimpApiClient", { enumerable: true, get: function () { return api_client_1.TestChimpApiClient; } });
22
+ __exportStar(require("./types"), exports);
23
+ __exportStar(require("./utils"), exports);
24
+ const testchimp_reporter_2 = require("./testchimp-reporter");
25
+ exports.default = testchimp_reporter_2.TestChimpReporter;
26
+ //# sourceMappingURL=reporter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reporter.js","sourceRoot":"","sources":["../src/reporter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2DAAyD;AAAhD,uHAAA,iBAAiB,OAAA;AAC1B,2CAAkD;AAAzC,gHAAA,kBAAkB,OAAA;AAC3B,0CAAwB;AACxB,0CAAwB;AAExB,6DAAyD;AACzD,kBAAe,sCAAiB,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * TrueCoverage runtime: injects CITestInfo into the browser so testchimp-rum-js can
3
+ * send the ci-test-info header on RUM ingest requests.
4
+ */
5
+ export * from './worldstate';
6
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,cAAc,cAAc,CAAC"}
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ /**
3
+ * TrueCoverage runtime: injects CITestInfo into the browser so testchimp-rum-js can
4
+ * send the ci-test-info header on RUM ingest requests.
5
+ */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
19
+ }) : function(o, v) {
20
+ o["default"] = v;
21
+ });
22
+ var __importStar = (this && this.__importStar) || (function () {
23
+ var ownKeys = function(o) {
24
+ ownKeys = Object.getOwnPropertyNames || function (o) {
25
+ var ar = [];
26
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
+ return ar;
28
+ };
29
+ return ownKeys(o);
30
+ };
31
+ return function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
+ __setModuleDefault(result, mod);
36
+ return result;
37
+ };
38
+ })();
39
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
40
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
41
+ };
42
+ Object.defineProperty(exports, "__esModule", { value: true });
43
+ const fs = __importStar(require("fs"));
44
+ const path = __importStar(require("path"));
45
+ const test_1 = require("@playwright/test");
46
+ const utils_1 = require("./utils");
47
+ __exportStar(require("./worldstate"), exports);
48
+ const BATCH_ID_FILENAME = '.testchimp-batch-invocation-id';
49
+ function readBatchInvocationId(projectRootDir) {
50
+ const fromEnv = process.env.TESTCHIMP_BATCH_INVOCATION_ID;
51
+ if (fromEnv)
52
+ return fromEnv;
53
+ const filePath = process.env.TESTCHIMP_BATCH_ID_FILE ||
54
+ path.join(projectRootDir, BATCH_ID_FILENAME);
55
+ try {
56
+ return fs.readFileSync(filePath, 'utf8').trim() || undefined;
57
+ }
58
+ catch {
59
+ return undefined;
60
+ }
61
+ }
62
+ test_1.test.beforeEach(async ({ page }, testInfo) => {
63
+ const project = testInfo.project;
64
+ const projectRootDir = project.rootDir ?? process.cwd();
65
+ const testsFolder = (0, utils_1.deriveTestsFolder)(projectRootDir);
66
+ const paths = (0, utils_1.derivePathsFromTestInfo)(testInfo, testsFolder, projectRootDir, false);
67
+ const ciTestInfo = {
68
+ folderPath: paths.folderPath,
69
+ fileName: paths.fileName,
70
+ suitePath: paths.suitePath,
71
+ testName: paths.testName,
72
+ };
73
+ const branchName = (0, utils_1.getBranchName)();
74
+ if (branchName)
75
+ ciTestInfo.branchName = branchName;
76
+ const env = process.env.TESTCHIMP_ENV ||
77
+ process.env.CI_ENVIRONMENT_NAME ||
78
+ process.env.NODE_ENV;
79
+ if (env)
80
+ ciTestInfo.environment = env;
81
+ const release = process.env.TESTCHIMP_RELEASE;
82
+ if (release)
83
+ ciTestInfo.release = release;
84
+ const batchInvocationId = readBatchInvocationId(projectRootDir);
85
+ if (batchInvocationId)
86
+ ciTestInfo.batchInvocationId = batchInvocationId;
87
+ const jsonString = JSON.stringify(ciTestInfo);
88
+ await page.addInitScript((info) => {
89
+ globalThis.__TC_CI_TEST_INFO =
90
+ info;
91
+ }, jsonString);
92
+ });
93
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,2CAA6B;AAC7B,2CAAwC;AACxC,mCAAoF;AACpF,+CAA6B;AAE7B,MAAM,iBAAiB,GAAG,gCAAgC,CAAC;AAE3D,SAAS,qBAAqB,CAAC,cAAsB;IACnD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC;IAC1D,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC;IAC5B,MAAM,QAAQ,GACZ,OAAO,CAAC,GAAG,CAAC,uBAAuB;QACnC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAC;IAC/C,IAAI,CAAC;QACH,OAAO,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,SAAS,CAAC;IAC/D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,WAAI,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,EAAE;IAC3C,MAAM,OAAO,GAAG,QAAQ,CAAC,OAA+B,CAAC;IACzD,MAAM,cAAc,GAAG,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IACxD,MAAM,WAAW,GAAG,IAAA,yBAAiB,EAAC,cAAc,CAAC,CAAC;IACtD,MAAM,KAAK,GAAG,IAAA,+BAAuB,EACnC,QAAoE,EACpE,WAAW,EACX,cAAc,EACd,KAAK,CACN,CAAC;IAEF,MAAM,UAAU,GAA4B;QAC1C,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,QAAQ,EAAE,KAAK,CAAC,QAAQ;KACzB,CAAC;IACF,MAAM,UAAU,GAAG,IAAA,qBAAa,GAAE,CAAC;IACnC,IAAI,UAAU;QAAE,UAAU,CAAC,UAAU,GAAG,UAAU,CAAC;IACnD,MAAM,GAAG,GACP,OAAO,CAAC,GAAG,CAAC,aAAa;QACzB,OAAO,CAAC,GAAG,CAAC,mBAAmB;QAC/B,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;IACvB,IAAI,GAAG;QAAE,UAAU,CAAC,WAAW,GAAG,GAAG,CAAC;IACtC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;IAC9C,IAAI,OAAO;QAAE,UAAU,CAAC,OAAO,GAAG,OAAO,CAAC;IAC1C,MAAM,iBAAiB,GAAG,qBAAqB,CAAC,cAAc,CAAC,CAAC;IAChE,IAAI,iBAAiB;QAAE,UAAU,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;IAExE,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAC9C,MAAM,IAAI,CAAC,aAAa,CACtB,CAAC,IAAY,EAAE,EAAE;QACd,UAAwD,CAAC,iBAAiB;YACzE,IAAI,CAAC;IACT,CAAC,EACD,UAAU,CACX,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,82 @@
1
+ import type { Reporter, FullConfig, Suite, TestCase, TestResult, TestStep, FullResult } from '@playwright/test/reporter';
2
+ import { TestChimpReporterOptions } from './types';
3
+ /**
4
+ * TestChimp Playwright Reporter
5
+ *
6
+ * Reports test execution data to the TestChimp backend for
7
+ * coverage tracking and traceability.
8
+ *
9
+ * @example
10
+ * // playwright.config.ts
11
+ * export default defineConfig({
12
+ * reporter: [
13
+ * ['playwright-testchimp/reporter', {
14
+ * verbose: true,
15
+ * reportOnlyFinalAttempt: true
16
+ * }]
17
+ * ]
18
+ * });
19
+ */
20
+ export declare class TestChimpReporter implements Reporter {
21
+ private static readonly DEFAULT_TRACE_MAX_BYTES;
22
+ private static readonly DEFAULT_TRACE_UPLOAD_TIMEOUT_MS;
23
+ private static readonly DEFAULT_TRACE_UPLOAD_RETRIES;
24
+ private config;
25
+ private options;
26
+ private apiClient;
27
+ private batchInvocationId;
28
+ private testsFolder;
29
+ private testExecutions;
30
+ private testRetryInfo;
31
+ private jobManifest;
32
+ private isEnabled;
33
+ private pendingOperations;
34
+ constructor(options?: TestChimpReporterOptions);
35
+ onBegin(config: FullConfig, suite: Suite): void;
36
+ private loadJobManifest;
37
+ /**
38
+ * Resolve jobId from the platform manifest.
39
+ * - No describe block: both parser and Playwright use suitePath [] → exact match.
40
+ * - Global describe(): parser only sees test.describe() so manifest has []; Playwright reports e.g. ["Suite"] → fallback with [].
41
+ */
42
+ private getJobFromManifest;
43
+ private getManifestDebugCandidates;
44
+ /**
45
+ * Build full job detail from all attempts for this test (from in-memory testExecutions).
46
+ * For step_end: currentAttemptIsFinal=false (current attempt in progress).
47
+ * For test_end: currentAttemptIsFinal=true, finalStatus/error from result.
48
+ * Past attempts are marked FAILED (retry implies they did not succeed).
49
+ */
50
+ private buildJobDetailFromAttempts;
51
+ /** Build current job detail for platform step_end (all attempts so far, current still in progress) */
52
+ private buildCurrentJobDetailForPlatform;
53
+ /** Build final job detail for platform test_end (all attempts with final status) */
54
+ private buildFinalJobDetailForPlatform;
55
+ onTestBegin(test: TestCase, result: TestResult): void;
56
+ onStepEnd(test: TestCase, result: TestResult, step: TestStep): void;
57
+ onTestEnd(test: TestCase, result: TestResult): Promise<void>;
58
+ private _onTestEndInner;
59
+ onEnd(result: FullResult): Promise<void>;
60
+ private getTestKey;
61
+ private scanTestRetries;
62
+ private buildReport;
63
+ private mapStatus;
64
+ /**
65
+ * Attach failure screenshots: failing steps first; if none, attach to last step (test-level failures e.g. ai.act).
66
+ */
67
+ private attachScreenshotsToFailingSteps;
68
+ private getTraceMaxBytes;
69
+ private isTraceAttachment;
70
+ private uploadTraceAttachmentIfPresent;
71
+ /**
72
+ * Generic Playwright pw:api leaf titles; use innermost enclosing test.step title instead.
73
+ */
74
+ private static readonly GENERIC_PW_API_TITLES;
75
+ private isGenericPwApiTitle;
76
+ /** Closest ancestor test.step (user/framework intent), e.g. ai.act wrapper. */
77
+ private getInnermostEnclosingTestStepTitle;
78
+ /** Single-line description: test.step / expect use title; generic pw:api uses enclosing test.step title when present. */
79
+ private getStepDescription;
80
+ private toPlaywrightError;
81
+ }
82
+ //# sourceMappingURL=testchimp-reporter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testchimp-reporter.d.ts","sourceRoot":"","sources":["../src/testchimp-reporter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,UAAU,EACV,KAAK,EACL,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,UAAU,EAEX,MAAM,2BAA2B,CAAC;AAKnC,OAAO,EACL,wBAAwB,EAQzB,MAAM,SAAS,CAAC;AA6BjB;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,iBAAkB,YAAW,QAAQ;IAChD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,uBAAuB,CAAoB;IACnE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,+BAA+B,CAAW;IAClE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,4BAA4B,CAAK;IACzD,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,OAAO,CAAqC;IACpD,OAAO,CAAC,SAAS,CAAmC;IACpD,OAAO,CAAC,iBAAiB,CAAc;IACvC,OAAO,CAAC,WAAW,CAAc;IAIjC,OAAO,CAAC,cAAc,CAA8C;IAGpE,OAAO,CAAC,aAAa,CAAqC;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