@testchimp/playwright 0.1.0 → 0.1.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/dist/runtime.d.ts +10 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +45 -35
- package/dist/runtime.js.map +1 -1
- package/dist/runtime.mjs +3 -3
- package/package.json +2 -2
package/dist/runtime.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* TrueCoverage runtime: injects CITestInfo into the browser so @testchimp/rum-js can
|
|
3
3
|
* send the ci-test-info header on RUM ingest requests.
|
|
4
|
+
*
|
|
5
|
+
* Prefer `installTrueCoverage(mergedTest)` on the same `test` object your specs use
|
|
6
|
+
* (e.g. `mergeTests` output from `fixtures/index.js`). The side-effect
|
|
7
|
+
* `import '@testchimp/playwright/runtime'` still registers on the root `@playwright/test`
|
|
8
|
+
* instance for backward compatibility.
|
|
4
9
|
*/
|
|
5
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Register TrueCoverage CI metadata injection on the given Playwright `test` object
|
|
12
|
+
* (including `mergeTests(...)` output). Returns the same instance for chaining.
|
|
13
|
+
*/
|
|
14
|
+
export declare function installTrueCoverage(test: any): any;
|
|
6
15
|
//# sourceMappingURL=runtime.d.ts.map
|
package/dist/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAqBH;;;GAGG;AAEH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,CAqClD"}
|
package/dist/runtime.js
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* TrueCoverage runtime: injects CITestInfo into the browser so @testchimp/rum-js can
|
|
4
4
|
* send the ci-test-info header on RUM ingest requests.
|
|
5
|
+
*
|
|
6
|
+
* Prefer `installTrueCoverage(mergedTest)` on the same `test` object your specs use
|
|
7
|
+
* (e.g. `mergeTests` output from `fixtures/index.js`). The side-effect
|
|
8
|
+
* `import '@testchimp/playwright/runtime'` still registers on the root `@playwright/test`
|
|
9
|
+
* instance for backward compatibility.
|
|
5
10
|
*/
|
|
6
11
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
12
|
if (k2 === undefined) k2 = k;
|
|
@@ -37,6 +42,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
37
42
|
};
|
|
38
43
|
})();
|
|
39
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.installTrueCoverage = installTrueCoverage;
|
|
40
46
|
const fs = __importStar(require("fs"));
|
|
41
47
|
const path = __importStar(require("path"));
|
|
42
48
|
const module_1 = require("module");
|
|
@@ -46,8 +52,7 @@ function readBatchInvocationId(projectRootDir) {
|
|
|
46
52
|
const fromEnv = process.env.TESTCHIMP_BATCH_INVOCATION_ID;
|
|
47
53
|
if (fromEnv)
|
|
48
54
|
return fromEnv;
|
|
49
|
-
const filePath = process.env.TESTCHIMP_BATCH_ID_FILE ||
|
|
50
|
-
path.join(projectRootDir, BATCH_ID_FILENAME);
|
|
55
|
+
const filePath = process.env.TESTCHIMP_BATCH_ID_FILE || path.join(projectRootDir, BATCH_ID_FILENAME);
|
|
51
56
|
try {
|
|
52
57
|
return fs.readFileSync(filePath, 'utf8').trim() || undefined;
|
|
53
58
|
}
|
|
@@ -55,40 +60,45 @@ function readBatchInvocationId(projectRootDir) {
|
|
|
55
60
|
return undefined;
|
|
56
61
|
}
|
|
57
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Register TrueCoverage CI metadata injection on the given Playwright `test` object
|
|
65
|
+
* (including `mergeTests(...)` output). Returns the same instance for chaining.
|
|
66
|
+
*/
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
68
|
+
function installTrueCoverage(test) {
|
|
69
|
+
test.beforeEach(async ({ page }, testInfo) => {
|
|
70
|
+
const project = testInfo.project;
|
|
71
|
+
const projectRootDir = project.rootDir ?? process.cwd();
|
|
72
|
+
const testsFolder = (0, utils_1.deriveTestsFolder)(projectRootDir);
|
|
73
|
+
const paths = (0, utils_1.derivePathsFromTestInfo)(testInfo, testsFolder, projectRootDir, false);
|
|
74
|
+
const ciTestInfo = {
|
|
75
|
+
folderPath: paths.folderPath,
|
|
76
|
+
fileName: paths.fileName,
|
|
77
|
+
suitePath: paths.suitePath,
|
|
78
|
+
testName: paths.testName,
|
|
79
|
+
};
|
|
80
|
+
const branchName = (0, utils_1.getBranchName)();
|
|
81
|
+
if (branchName)
|
|
82
|
+
ciTestInfo.branchName = branchName;
|
|
83
|
+
const env = process.env.TESTCHIMP_ENV || process.env.CI_ENVIRONMENT_NAME || process.env.NODE_ENV;
|
|
84
|
+
if (env)
|
|
85
|
+
ciTestInfo.environment = env;
|
|
86
|
+
const release = process.env.TESTCHIMP_RELEASE;
|
|
87
|
+
if (release)
|
|
88
|
+
ciTestInfo.release = release;
|
|
89
|
+
const batchInvocationId = readBatchInvocationId(projectRootDir);
|
|
90
|
+
if (batchInvocationId)
|
|
91
|
+
ciTestInfo.batchInvocationId = batchInvocationId;
|
|
92
|
+
const jsonString = JSON.stringify(ciTestInfo);
|
|
93
|
+
await page.addInitScript((info) => {
|
|
94
|
+
globalThis.__TC_CI_TEST_INFO = info;
|
|
95
|
+
}, jsonString);
|
|
96
|
+
});
|
|
97
|
+
return test;
|
|
98
|
+
}
|
|
58
99
|
// IMPORTANT: resolve @playwright/test from the *consumer* project, not from this package.
|
|
59
|
-
// This avoids "Requiring @playwright/test second time" when developing via `file:`/linked installs.
|
|
60
100
|
const pwRequire = (0, module_1.createRequire)(path.join(process.cwd(), 'package.json'));
|
|
61
101
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
62
|
-
const { test } = pwRequire('@playwright/test');
|
|
63
|
-
|
|
64
|
-
const project = testInfo.project;
|
|
65
|
-
const projectRootDir = project.rootDir ?? process.cwd();
|
|
66
|
-
const testsFolder = (0, utils_1.deriveTestsFolder)(projectRootDir);
|
|
67
|
-
const paths = (0, utils_1.derivePathsFromTestInfo)(testInfo, testsFolder, projectRootDir, false);
|
|
68
|
-
const ciTestInfo = {
|
|
69
|
-
folderPath: paths.folderPath,
|
|
70
|
-
fileName: paths.fileName,
|
|
71
|
-
suitePath: paths.suitePath,
|
|
72
|
-
testName: paths.testName,
|
|
73
|
-
};
|
|
74
|
-
const branchName = (0, utils_1.getBranchName)();
|
|
75
|
-
if (branchName)
|
|
76
|
-
ciTestInfo.branchName = branchName;
|
|
77
|
-
const env = process.env.TESTCHIMP_ENV ||
|
|
78
|
-
process.env.CI_ENVIRONMENT_NAME ||
|
|
79
|
-
process.env.NODE_ENV;
|
|
80
|
-
if (env)
|
|
81
|
-
ciTestInfo.environment = env;
|
|
82
|
-
const release = process.env.TESTCHIMP_RELEASE;
|
|
83
|
-
if (release)
|
|
84
|
-
ciTestInfo.release = release;
|
|
85
|
-
const batchInvocationId = readBatchInvocationId(projectRootDir);
|
|
86
|
-
if (batchInvocationId)
|
|
87
|
-
ciTestInfo.batchInvocationId = batchInvocationId;
|
|
88
|
-
const jsonString = JSON.stringify(ciTestInfo);
|
|
89
|
-
await page.addInitScript((info) => {
|
|
90
|
-
globalThis.__TC_CI_TEST_INFO =
|
|
91
|
-
info;
|
|
92
|
-
}, jsonString);
|
|
93
|
-
});
|
|
102
|
+
const { test: rootTest } = pwRequire('@playwright/test');
|
|
103
|
+
installTrueCoverage(rootTest);
|
|
94
104
|
//# sourceMappingURL=runtime.js.map
|
package/dist/runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mapp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
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createRequire } from 'module';
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
// but allow ESM consumers to `import 'playwright-testchimp/runtime'`.
|
|
3
|
+
// Copied to `dist/runtime.mjs` after `tsc`. Loads `./runtime.js` (CJS) for side effects + named exports.
|
|
5
4
|
const require = createRequire(import.meta.url);
|
|
6
5
|
const cjs = require('./runtime.js');
|
|
7
6
|
|
|
7
|
+
export const installTrueCoverage = cjs.installTrueCoverage;
|
|
8
|
+
|
|
8
9
|
export * from './worldstate.mjs';
|
|
9
10
|
export default cjs;
|
|
10
|
-
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testchimp/playwright",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Playwright reporter for TestChimp test execution tracking and coverage reporting",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"dist/"
|
|
28
28
|
],
|
|
29
29
|
"scripts": {
|
|
30
|
-
"build": "tsc",
|
|
30
|
+
"build": "tsc && cp esm/runtime-entry.mjs dist/runtime.mjs",
|
|
31
31
|
"watch": "tsc --watch",
|
|
32
32
|
"clean": "rm -rf dist",
|
|
33
33
|
"test": "npm run build && node --test test/*.test.js"
|