@empiricalrun/playwright-utils 0.7.4 → 0.7.6

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @empiricalrun/playwright-utils
2
2
 
3
+ ## 0.7.6
4
+
5
+ ### Patch Changes
6
+
7
+ - 99b9f75: fix: remove unused code and refactor
8
+
9
+ ## 0.7.5
10
+
11
+ ### Patch Changes
12
+
13
+ - 175e60d: fix: execution order of playwright reporter
14
+
3
15
  ## 0.7.4
4
16
 
5
17
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7D,eAAO,MAAM,UAAU,EAAE,oBAyBxB,CAAC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAE7D,eAAO,MAAM,UAAU,EAAE,oBAwBxB,CAAC"}
package/dist/config.js CHANGED
@@ -9,10 +9,9 @@ exports.baseConfig = {
9
9
  retries: "true" ? 2 : 0,
10
10
  workers: undefined,
11
11
  reporter: [
12
- ["./node_modules/@empiricalrun/playwright-utils/dist/reporter/custom.js"],
13
- ["json", { outputFile: "playwright-report/summary.json" }],
14
12
  ["list"], // For real-time reporting on CI terminal (vs. the default "dot" reporter)
15
- // ["html", { outputFolder: "test-results/html" }], // Original html reporter
13
+ ["json", { outputFile: "playwright-report/summary.json" }],
14
+ ["./node_modules/@empiricalrun/playwright-utils/dist/reporter/custom.js"],
16
15
  ],
17
16
  use: {
18
17
  trace: "on",
@@ -20,28 +20,14 @@ export type TestResultOutput = {
20
20
  type: "stdout" | "stderr";
21
21
  };
22
22
  export declare const kOutputSymbol: unique symbol;
23
- type Annotation = {
24
- title: string;
25
- message: string;
26
- location?: Location;
27
- };
28
23
  type ErrorDetails = {
29
24
  message: string;
30
25
  location?: Location;
31
26
  };
32
27
  export declare const isTTY: boolean, ttyWidth: number, colors: any;
33
- export declare function formatFailure(config: FullConfig, test: TestCase, options?: {
34
- index?: number;
35
- includeStdio?: boolean;
36
- includeAttachments?: boolean;
37
- }): {
38
- message: string;
39
- annotations: Annotation[];
40
- };
41
28
  export declare function formatResultFailure(test: TestCase, result: TestResult, initialIndent: string, highlightCode: boolean): ErrorDetails[];
42
29
  export declare function relativeFilePath(config: FullConfig, file: string): string;
43
30
  export declare function stepSuffix(step: TestStep | undefined): string;
44
- export declare function formatTestTitle(config: FullConfig, test: TestCase, step?: TestStep, omitLocation?: boolean): string;
45
31
  export declare function formatError(error: TestError, highlightCode: boolean): ErrorDetails;
46
32
  export declare function separator(text?: string): string;
47
33
  export declare function prepareErrorStack(stack: string): {
@@ -50,18 +36,5 @@ export declare function prepareErrorStack(stack: string): {
50
36
  location?: Location;
51
37
  };
52
38
  export declare function stripAnsiEscapes(str: string): string;
53
- export declare function resolveOutputFile(reporterName: string, options: {
54
- configDir: string;
55
- outputDir?: string;
56
- fileName?: string;
57
- outputFile?: string;
58
- default?: {
59
- fileName: string;
60
- outputDir: string;
61
- };
62
- }): {
63
- outputFile: string;
64
- outputDir?: string;
65
- } | undefined;
66
39
  export {};
67
40
  //# sourceMappingURL=base.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/reporter/base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;AAEH,OAAO,KAAK,EACV,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,UAAU,EACV,QAAQ,EACT,MAAM,2BAA2B,CAAC;AAWnC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,IAAI,EAAE,QAAQ,GAAG,QAAQ,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AAI,EAAE,QAAQ,EACd,MAAM,EAAE,UAAU,EAClB,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,OAAO,GACrB,YAAY,EAAE,CAyBhB;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEzE;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,UAMpD;AAED,wBAAgB,WAAW,CACzB,KAAK,EAAE,SAAS,EAChB,aAAa,EAAE,OAAO,GACrB,YAAY,CA+Bd;AAED,wBAAgB,SAAS,CAAC,IAAI,GAAE,MAAW,GAAG,MAAM,CAInD;AAMD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB,CAmBA;AAOD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEpD"}
@@ -19,12 +19,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
19
19
  };
20
20
  var _a;
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.resolveOutputFile = exports.stripAnsiEscapes = exports.prepareErrorStack = exports.separator = exports.formatError = exports.formatTestTitle = exports.stepSuffix = exports.relativeFilePath = exports.formatResultFailure = exports.formatFailure = exports.colors = exports.ttyWidth = exports.isTTY = exports.kOutputSymbol = void 0;
22
+ exports.stripAnsiEscapes = exports.prepareErrorStack = exports.separator = exports.formatError = exports.stepSuffix = exports.relativeFilePath = exports.formatResultFailure = exports.colors = exports.ttyWidth = exports.isTTY = exports.kOutputSymbol = void 0;
23
23
  const path_1 = __importDefault(require("path"));
24
- // @ts-ignore
25
- const utils_1 = require("playwright-core/lib/utils");
26
24
  const utilsBundle_1 = require("playwright-core/lib/utilsBundle");
27
- const util_1 = require("./util");
28
25
  exports.kOutputSymbol = Symbol("output");
29
26
  _a = (() => {
30
27
  let isTTY = !!process.stdout.isTTY;
@@ -70,99 +67,6 @@ _a = (() => {
70
67
  };
71
68
  return { isTTY, ttyWidth, colors };
72
69
  })(), exports.isTTY = _a.isTTY, exports.ttyWidth = _a.ttyWidth, exports.colors = _a.colors;
73
- function formatFailure(config, test, options = {}) {
74
- const { index, includeStdio, includeAttachments = true } = options;
75
- const lines = [];
76
- const title = formatTestTitle(config, test);
77
- const annotations = [];
78
- const header = formatTestHeader(config, test, {
79
- indent: " ",
80
- index,
81
- mode: "error",
82
- });
83
- lines.push(exports.colors.red(header));
84
- for (const result of test.results) {
85
- const resultLines = [];
86
- const errors = formatResultFailure(test, result, " ", exports.colors.enabled);
87
- if (!errors.length)
88
- continue;
89
- const retryLines = [];
90
- if (result.retry) {
91
- retryLines.push("");
92
- retryLines.push(exports.colors.gray(separator(` Retry #${result.retry}`)));
93
- }
94
- resultLines.push(...retryLines);
95
- resultLines.push(...errors.map((error) => "\n" + error.message));
96
- if (includeAttachments) {
97
- for (let i = 0; i < result.attachments.length; ++i) {
98
- const attachment = result.attachments[i];
99
- const hasPrintableContent = attachment?.contentType.startsWith("text/");
100
- if (!attachment || (!attachment.path && !hasPrintableContent))
101
- continue;
102
- resultLines.push("");
103
- resultLines.push(exports.colors.cyan(separator(` attachment #${i + 1}: ${attachment.name} (${attachment.contentType})`)));
104
- if (attachment.path) {
105
- const relativePath = path_1.default.relative(process.cwd(), attachment.path);
106
- resultLines.push(exports.colors.cyan(` ${relativePath}`));
107
- // Make this extensible
108
- if (attachment.name === "trace") {
109
- const packageManagerCommand = (0, utils_1.getPackageManagerExecCommand)();
110
- resultLines.push(exports.colors.cyan(` Usage:`));
111
- resultLines.push("");
112
- resultLines.push(exports.colors.cyan(` ${packageManagerCommand} playwright show-trace ${quotePathIfNeeded(relativePath)}`));
113
- resultLines.push("");
114
- }
115
- }
116
- else {
117
- if (attachment.contentType.startsWith("text/") && attachment.body) {
118
- let text = attachment.body.toString();
119
- if (text.length > 300)
120
- text = text.slice(0, 300) + "...";
121
- for (const line of text.split("\n"))
122
- resultLines.push(exports.colors.cyan(` ${line}`));
123
- }
124
- }
125
- resultLines.push(exports.colors.cyan(separator(" ")));
126
- }
127
- }
128
- const output = (result[exports.kOutputSymbol] || []);
129
- if (includeStdio && output.length) {
130
- const outputText = output
131
- .map(({ chunk, type }) => {
132
- const text = chunk.toString("utf8");
133
- if (type === "stderr")
134
- return exports.colors.red(stripAnsiEscapes(text));
135
- return text;
136
- })
137
- .join("");
138
- resultLines.push("");
139
- resultLines.push(exports.colors.gray(separator("--- Test output")) +
140
- "\n\n" +
141
- outputText +
142
- "\n" +
143
- separator());
144
- }
145
- for (const error of errors) {
146
- annotations.push({
147
- location: error.location,
148
- title,
149
- message: [header, ...retryLines, error.message].join("\n"),
150
- });
151
- }
152
- lines.push(...resultLines);
153
- }
154
- lines.push("");
155
- return {
156
- message: lines.join("\n"),
157
- annotations,
158
- };
159
- }
160
- exports.formatFailure = formatFailure;
161
- function quotePathIfNeeded(path) {
162
- if (/\s/.test(path))
163
- return `"${path}"`;
164
- return path;
165
- }
166
70
  function formatResultFailure(test, result, initialIndent, highlightCode) {
167
71
  const errorDetails = [];
168
72
  if (result.status === "passed" && test.expectedStatus === "failed") {
@@ -189,9 +93,6 @@ function relativeFilePath(config, file) {
189
93
  return path_1.default.relative(config.rootDir, file) || path_1.default.basename(file);
190
94
  }
191
95
  exports.relativeFilePath = relativeFilePath;
192
- function relativeTestPath(config, test) {
193
- return relativeFilePath(config, test.location.file);
194
- }
195
96
  function stepSuffix(step) {
196
97
  const stepTitles = step ? step.titlePath() : [];
197
98
  return stepTitles
@@ -200,44 +101,6 @@ function stepSuffix(step) {
200
101
  .join("");
201
102
  }
202
103
  exports.stepSuffix = stepSuffix;
203
- function formatTestTitle(config, test, step, omitLocation = false) {
204
- // root, project, file, ...describes, test
205
- const [, projectName, , ...titles] = test.titlePath();
206
- let location;
207
- if (omitLocation)
208
- location = `${relativeTestPath(config, test)}`;
209
- else
210
- location = `${relativeTestPath(config, test)}:${step?.location?.line ?? test.location.line}:${step?.location?.column ?? test.location.column}`;
211
- const projectTitle = projectName ? `[${projectName}] › ` : "";
212
- return `${projectTitle}${location} › ${titles.join(" › ")}${stepSuffix(step)}`;
213
- }
214
- exports.formatTestTitle = formatTestTitle;
215
- function formatTestHeader(config, test, options = {}) {
216
- const title = formatTestTitle(config, test);
217
- const header = `${options.indent || ""}${options.index ? options.index + ") " : ""}${title}`;
218
- let fullHeader = header;
219
- // Render the path to the deepest failing test.step.
220
- if (options.mode === "error") {
221
- const stepPaths = new Set();
222
- for (const result of test.results.filter((r) => !!r.errors.length)) {
223
- const stepPath = [];
224
- const visit = (steps) => {
225
- const errors = steps.filter((s) => s.error);
226
- if (errors.length > 1)
227
- return;
228
- if (errors.length === 1 && errors[0]?.category === "test.step") {
229
- stepPath.push(errors[0].title);
230
- visit(errors[0].steps);
231
- }
232
- };
233
- visit(result.steps);
234
- stepPaths.add(["", ...stepPath].join(" › "));
235
- }
236
- fullHeader =
237
- header + (stepPaths.size === 1 ? stepPaths.values().next().value : "");
238
- }
239
- return separator(fullHeader);
240
- }
241
104
  function formatError(error, highlightCode) {
242
105
  const message = error.message || error.value || "";
243
106
  const stack = error.stack;
@@ -312,39 +175,3 @@ exports.stripAnsiEscapes = stripAnsiEscapes;
312
175
  function belongsToNodeModules(file) {
313
176
  return file.includes(`${path_1.default.sep}node_modules${path_1.default.sep}`);
314
177
  }
315
- function resolveFromEnv(name) {
316
- const value = process.env[name];
317
- if (value)
318
- return path_1.default.resolve(process.cwd(), value);
319
- return undefined;
320
- }
321
- // In addition to `outputFile` the function returns `outputDir` which should
322
- // be cleaned up if present by some reporters contract.
323
- function resolveOutputFile(reporterName, options) {
324
- const name = reporterName.toUpperCase();
325
- let outputFile;
326
- if (options.outputFile)
327
- outputFile = path_1.default.resolve(options.configDir, options.outputFile);
328
- if (!outputFile)
329
- outputFile = resolveFromEnv(`PLAYWRIGHT_${name}_OUTPUT_FILE`);
330
- // Return early to avoid deleting outputDir.
331
- if (outputFile)
332
- return { outputFile };
333
- let outputDir;
334
- if (options.outputDir)
335
- outputDir = path_1.default.resolve(options.configDir, options.outputDir);
336
- if (!outputDir)
337
- outputDir = resolveFromEnv(`PLAYWRIGHT_${name}_OUTPUT_DIR`);
338
- if (!outputDir && options.default)
339
- outputDir = (0, util_1.resolveReporterOutputPath)(options.default.outputDir, options.configDir, undefined);
340
- if (!outputFile) {
341
- const reportName = options.fileName ??
342
- process.env[`PLAYWRIGHT_${name}_OUTPUT_NAME`] ??
343
- options.default?.fileName;
344
- if (!reportName)
345
- return undefined;
346
- outputFile = path_1.default.resolve(outputDir ?? process.cwd(), reportName);
347
- }
348
- return { outputFile, outputDir };
349
- }
350
- exports.resolveOutputFile = resolveOutputFile;
@@ -1 +1 @@
1
- {"version":3,"file":"custom.d.ts","sourceRoot":"","sources":["../../src/reporter/custom.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EAEV,KAAK,EACL,QAAQ,IAAI,cAAc,EAC1B,SAAS,EACT,UAAU,IAAI,gBAAgB,EAE/B,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAML,UAAU,EAMX,MAAM,2BAA2B,CAAC;AAgBnC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAwC/C,QAAA,MAAM,iBAAiB,UAAoC,CAAC;AAC5D,KAAK,oBAAoB,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAM/D,KAAK,mBAAmB,GAAG;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,oBAAoB,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kBAAkB,CAAC,EAAE,MAAM,C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N;IACd,OAAO,CAAC,eAAe,CAAmB;gBAE9B,OAAO,EAAE,mBAAmB;IAIxC,aAAa;IAIb,QAAQ;IAER,QAAQ;IAER,WAAW;IAEX,SAAS;IAET,OAAO,IAAI,IAAI;IAIf,WAAW;IAEX,SAAS,CAAC,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,gBAAgB;IA2BxD,WAAW,CAAC,MAAM,EAAE,UAAU;IAI9B,OAAO,CAAC,KAAK,EAAE,KAAK;IAYpB,eAAe,IAAI;QACjB,YAAY,EAAE,MAAM,CAAC;QACrB,IAAI,EAAE,oBAAoB,CAAC;QAC3B,kBAAkB,EAAE,MAAM,CAAC;QAC3B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;QACzB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;KAC1B;IAsBD,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO;IASxD,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IAIzB,KAAK,CAAC,MAAM,EAAE,UAAU;IA6ExB,MAAM;CA8Bb;AAkCD,wBAAsB,cAAc,CAClC,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,IAAI,GAAE,MAAoB,EAC1B,IAAI,CAAC,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,MAAM,iBAqBhB;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAsBhE;AAqiBD,eAAe,YAAY,CAAC"}
@@ -111,16 +111,6 @@ class HtmlReporter {
111
111
  :*/ this._options.port,
112
112
  };
113
113
  }
114
- // override onTestBegin(test: TestCasePublic) {
115
- // console.log("onTestBegin, test: ", test.title);
116
- // }
117
- // override onTestEnd(test: TestCasePublic, result: TestResultPublic) {
118
- // console.log("onTestEnd, test: ", test.title, result.status);
119
- // // check path and start upload
120
- // result.attachments.forEach((attachment) => {
121
- // console.log("attachment: ", attachment);
122
- // });
123
- // }
124
114
  _isSubdirectory(parentDir, dir) {
125
115
  const relativePath = path_1.default.relative(parentDir, dir);
126
116
  return (!!relativePath &&
@@ -136,12 +126,11 @@ class HtmlReporter {
136
126
  // await removeFolders([this._outputFolder]);
137
127
  const builder = new HtmlBuilder(this.config, this._outputFolder, this._attachmentsBaseURL);
138
128
  this._buildResult = await builder.build(this.config.metadata, projectSuites, result, this._topLevelErrors);
139
- // upload trace directory
129
+ const startTime = new Date().getTime();
140
130
  if (!process.env.PROJECT_NAME || !process.env.TEST_RUN_GITHUB_ACTION_ID) {
141
- // Skipping upload of trace directory since PROJECT_NAME or TEST_RUN_GITHUB_ACTION_ID is not set,
131
+ // Skipping uploads since PROJECT_NAME or TEST_RUN_GITHUB_ACTION_ID is not set,
142
132
  return;
143
133
  }
144
- const startTime = new Date().getTime();
145
134
  console.log("Starting final report upload at: ", new Intl.DateTimeFormat("en-US", {
146
135
  hour: "2-digit",
147
136
  minute: "2-digit",
@@ -156,22 +145,19 @@ class HtmlReporter {
156
145
  "/trace",
157
146
  uploadBucket: "test-report",
158
147
  }),
159
- // upload summary.json
148
+ // upload index.html
160
149
  (0, upload_1.uploadDirectory)({
161
150
  sourceDir: this._outputFolder,
162
- fileList: [
163
- path_1.default.join(this._outputFolder, "summary.json"),
164
- // path.join(this._outputFolder, "data", ".last-run.json"),
165
- ],
151
+ fileList: [path_1.default.join(this._outputFolder, "index.html")],
166
152
  destinationDir: process.env.PROJECT_NAME +
167
153
  "/" +
168
154
  process.env.TEST_RUN_GITHUB_ACTION_ID,
169
155
  uploadBucket: "test-report",
170
156
  }),
171
- // upload index.html
157
+ // upload summary.json
172
158
  (0, upload_1.uploadDirectory)({
173
159
  sourceDir: this._outputFolder,
174
- fileList: [path_1.default.join(this._outputFolder, "index.html")],
160
+ fileList: [path_1.default.join(this._outputFolder, "summary.json")],
175
161
  destinationDir: process.env.PROJECT_NAME +
176
162
  "/" +
177
163
  process.env.TEST_RUN_GITHUB_ACTION_ID,
@@ -1 +1 @@
1
- {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../src/reporter/upload.ts"],"names":[],"mappings":"AAsBA,UAAU,OAAO;IACf,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB;AA+GD,wBAAsB,eAAe,CAAC,EACpC,SAAS,EACT,QAAQ,EACR,cAAc,EACd,YAAY,GACb,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,OAAO,CAAC,CAYnB"}
1
+ {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../src/reporter/upload.ts"],"names":[],"mappings":"AAsBA,UAAU,OAAO;IACf,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB;AAyGD,wBAAsB,eAAe,CAAC,EACpC,SAAS,EACT,QAAQ,EACR,cAAc,EACd,YAAY,GACb,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,OAAO,CAAC,CAYnB"}
@@ -63,18 +63,12 @@ const run = async (config) => {
63
63
  let files;
64
64
  if (config.fileList) {
65
65
  files = config.fileList;
66
- // console.log("fileList", files);
67
66
  }
68
67
  else {
69
68
  files = getFileList(config.sourceDir);
70
- // console.log("files", files);
71
69
  }
72
70
  await Promise.all(files.map(async (file) => {
73
- // console.log(file);
74
71
  const fileStream = fs.readFileSync(file);
75
- // console.log(config.sourceDir);
76
- // console.log(config.destinationDir);
77
- //const fileName = file.replace(/^.*[\\\/]/, "");
78
72
  const fileName = file.replace(config.sourceDir, "");
79
73
  const fileKey = path_1.default.join(config.destinationDir !== "" ? config.destinationDir : config.sourceDir, fileName);
80
74
  if (fileKey.includes(".gitkeep"))
@@ -14,49 +14,6 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  /// <reference types="node" />
17
- import type { TestInfoError } from "@playwright/test";
18
- import type { Location } from "@playwright/test/reporter";
19
- import type { RawStack } from "./types";
20
- export type StackFrame = {
21
- file: string;
22
- line: number;
23
- column: number;
24
- function?: string;
25
- };
26
- export declare function filterStackTrace(e: Error): {
27
- message: string;
28
- stack: string;
29
- };
30
- export declare function filterStackFile(file: string): boolean;
31
- export declare function filteredStackTrace(rawStack: RawStack): StackFrame[];
32
- export declare function serializeError(error: Error | any): TestInfoError;
33
- export type Matcher = (value: string) => boolean;
34
- export type TestFileFilter = {
35
- re?: RegExp;
36
- exact?: string;
37
- line: number | null;
38
- column: number | null;
39
- };
40
- export declare function createFileFiltersFromArguments(args: string[]): TestFileFilter[];
41
- export declare function createFileMatcherFromArguments(args: string[]): Matcher;
42
- export declare function createFileMatcher(patterns: string | RegExp | (string | RegExp)[]): Matcher;
43
- export declare function createTitleMatcher(patterns: RegExp | RegExp[]): Matcher;
44
- export declare function mergeObjects<A extends object, B extends object, C extends object>(a: A | undefined | void, b: B | undefined | void, c: B | undefined | void): A & B & C;
45
- export declare function forceRegExp(pattern: string): RegExp;
46
- export declare function relativeFilePath(file: string): string;
47
- export declare function formatLocation(location: Location): string;
48
- export declare function errorWithFile(file: string, message: string): Error;
49
- export declare function expectTypes(receiver: any, types: string[], matcherName: string): void;
50
- export declare const windowsFilesystemFriendlyLength = 60;
51
- export declare function trimLongString(s: string, length?: number): string;
52
- export declare function addSuffixToFilePath(filePath: string, suffix: string): string;
53
- export declare function sanitizeFilePathBeforeExtension(filePath: string): string;
54
- /**
55
- * Returns absolute path contained within parent directory.
56
- */
57
- export declare function getContainedPath(parentPath: string, subPath?: string): string | null;
58
- export declare const debugTest: any;
59
- export declare const callLogText: any;
60
17
  export declare function getPackageJsonPath(folderPath: string): string;
61
18
  export declare function resolveReporterOutputPath(defaultValue: string, configDir: string, configValue: string | undefined): string;
62
19
  export declare function normalizeAndSaveAttachment(outputPath: string, name: string, options?: {
@@ -69,6 +26,4 @@ export declare function normalizeAndSaveAttachment(outputPath: string, name: str
69
26
  body?: Buffer | undefined;
70
27
  contentType: string;
71
28
  }>;
72
- export declare function fileIsModule(file: string): boolean;
73
- export declare function resolveImportSpecifierExtension(resolved: string, isPathMapping: boolean, isESM: boolean): string | undefined;
74
29
  //# sourceMappingURL=util.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/reporter/util.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAsB1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAOxC,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,KAAK,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAa7E;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,WAM3C;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG,UAAU,EAAE,CASnE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,GAAG,GAAG,aAAa,CAKhE;AAED,MAAM,MAAM,OAAO,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;AAEjD,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,GA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B7D;AAED,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,GAAG,SAAS,UAMhC;AAED,wBAAsB,0BAA0B,CAC9C,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAO,GAC5E,OAAO,CAAC;IACT,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC,CAyCD"}
@@ -18,212 +18,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
18
18
  return (mod && mod.__esModule) ? mod : { "default": mod };
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.resolveImportSpecifierExtension = exports.fileIsModule = exports.normalizeAndSaveAttachment = exports.resolveReporterOutputPath = exports.getPackageJsonPath = exports.callLogText = exports.debugTest = exports.getContainedPath = exports.sanitizeFilePathBeforeExtension = exports.addSuffixToFilePath = exports.trimLongString = exports.windowsFilesystemFriendlyLength = exports.expectTypes = exports.errorWithFile = exports.formatLocation = exports.relativeFilePath = exports.forceRegExp = exports.mergeObjects = exports.createTitleMatcher = exports.createFileMatcher = exports.createFileMatcherFromArguments = exports.createFileFiltersFromArguments = exports.serializeError = exports.filteredStackTrace = exports.filterStackFile = exports.filterStackTrace = void 0;
21
+ exports.normalizeAndSaveAttachment = exports.resolveReporterOutputPath = exports.getPackageJsonPath = void 0;
22
22
  const fs_1 = __importDefault(require("fs"));
23
23
  const path_1 = __importDefault(require("path"));
24
24
  const utils_1 = require("playwright-core/lib/utils");
25
25
  const utilsBundle_1 = require("playwright-core/lib/utilsBundle");
26
- const url_1 = __importDefault(require("url"));
27
- const util_1 = __importDefault(require("util"));
28
- const PLAYWRIGHT_TEST_PATH = path_1.default.join(__dirname, "..");
29
- const PLAYWRIGHT_CORE_PATH = path_1.default.dirname(require.resolve("playwright-core/package.json"));
30
- function filterStackTrace(e) {
31
- const name = e.name ? e.name + ": " : "";
32
- // if (process.env.PWDEBUGIMPL)
33
- // return { message: name + e.message, stack: e.stack || "" };
34
- const stackLines = (0, utils_1.stringifyStackFrames)(filteredStackTrace(e.stack?.split("\n") || []));
35
- return {
36
- message: name + e.message,
37
- // @ts-ignore - not able to get types from playwright-core
38
- stack: `${name}${e.message}${stackLines.map((line) => "\n" + line).join("")}`,
39
- };
40
- }
41
- exports.filterStackTrace = filterStackTrace;
42
- function filterStackFile(file) {
43
- if ( /*!process.env.PWDEBUGIMPL &&*/file.startsWith(PLAYWRIGHT_TEST_PATH))
44
- return false;
45
- if ( /*!process.env.PWDEBUGIMPL &&*/file.startsWith(PLAYWRIGHT_CORE_PATH))
46
- return false;
47
- return true;
48
- }
49
- exports.filterStackFile = filterStackFile;
50
- function filteredStackTrace(rawStack) {
51
- const frames = [];
52
- for (const line of rawStack) {
53
- const frame = (0, utilsBundle_1.parseStackTraceLine)(line);
54
- if (!frame || !frame.file)
55
- continue;
56
- if (!filterStackFile(frame.file))
57
- continue;
58
- frames.push(frame);
59
- }
60
- return frames;
61
- }
62
- exports.filteredStackTrace = filteredStackTrace;
63
- function serializeError(error) {
64
- if (error instanceof Error)
65
- return filterStackTrace(error);
66
- return {
67
- value: util_1.default.inspect(error),
68
- };
69
- }
70
- exports.serializeError = serializeError;
71
- function createFileFiltersFromArguments(args) {
72
- return args.map((arg) => {
73
- const match = /^(.*?):(\d+):?(\d+)?$/.exec(arg);
74
- // !!ARUSH
75
- return {
76
- re: forceRegExp(match ? (match[1] ?? "") : arg),
77
- line: match ? parseInt(match[2] ?? "", 10) : null,
78
- column: match?.[3] ? parseInt(match[3], 10) : null,
79
- };
80
- });
81
- }
82
- exports.createFileFiltersFromArguments = createFileFiltersFromArguments;
83
- function createFileMatcherFromArguments(args) {
84
- const filters = createFileFiltersFromArguments(args);
85
- return createFileMatcher(filters.map((filter) => filter.re || filter.exact || ""));
86
- }
87
- exports.createFileMatcherFromArguments = createFileMatcherFromArguments;
88
- function createFileMatcher(patterns) {
89
- const reList = [];
90
- const filePatterns = [];
91
- for (const pattern of Array.isArray(patterns) ? patterns : [patterns]) {
92
- // @empiricalrun
93
- if ((0, utils_1.isRegExp)(pattern) && typeof pattern !== "string") {
94
- reList.push(pattern);
95
- }
96
- else {
97
- // @empiricalrun
98
- if (typeof pattern !== "string")
99
- continue;
100
- if (!pattern.startsWith("**/"))
101
- filePatterns.push("**/" + pattern);
102
- else
103
- filePatterns.push(pattern);
104
- }
105
- }
106
- return (filePath) => {
107
- for (const re of reList) {
108
- re.lastIndex = 0;
109
- if (re.test(filePath))
110
- return true;
111
- }
112
- // Windows might still receive unix style paths from Cygwin or Git Bash.
113
- // Check against the file url as well.
114
- if (path_1.default.sep === "\\") {
115
- const fileURL = url_1.default.pathToFileURL(filePath).href;
116
- for (const re of reList) {
117
- re.lastIndex = 0;
118
- if (re.test(fileURL))
119
- return true;
120
- }
121
- }
122
- for (const pattern of filePatterns) {
123
- if ((0, utilsBundle_1.minimatch)(filePath, pattern, { nocase: true, dot: true }))
124
- return true;
125
- }
126
- return false;
127
- };
128
- }
129
- exports.createFileMatcher = createFileMatcher;
130
- function createTitleMatcher(patterns) {
131
- const reList = Array.isArray(patterns) ? patterns : [patterns];
132
- return (value) => {
133
- for (const re of reList) {
134
- re.lastIndex = 0;
135
- if (re.test(value))
136
- return true;
137
- }
138
- return false;
139
- };
140
- }
141
- exports.createTitleMatcher = createTitleMatcher;
142
- function mergeObjects(a, b, c) {
143
- const result = { ...a };
144
- for (const x of [b, c].filter(Boolean)) {
145
- for (const [name, value] of Object.entries(x)) {
146
- if (!Object.is(value, undefined))
147
- result[name] = value;
148
- }
149
- }
150
- return result;
151
- }
152
- exports.mergeObjects = mergeObjects;
153
- function forceRegExp(pattern) {
154
- const match = pattern.match(/^\/(.*)\/([gi]*)$/);
155
- // @empiricalrun
156
- if (match)
157
- return new RegExp(match[1] ?? "", match[2]);
158
- return new RegExp(pattern, "gi");
159
- }
160
- exports.forceRegExp = forceRegExp;
161
- function relativeFilePath(file) {
162
- if (!path_1.default.isAbsolute(file))
163
- return file;
164
- return path_1.default.relative(process.cwd(), file);
165
- }
166
- exports.relativeFilePath = relativeFilePath;
167
- function formatLocation(location) {
168
- return (relativeFilePath(location.file) +
169
- ":" +
170
- location.line +
171
- ":" +
172
- location.column);
173
- }
174
- exports.formatLocation = formatLocation;
175
- function errorWithFile(file, message) {
176
- return new Error(`${relativeFilePath(file)}: ${message}`);
177
- }
178
- exports.errorWithFile = errorWithFile;
179
- function expectTypes(receiver, types, matcherName) {
180
- if (typeof receiver !== "object" ||
181
- !types.includes(receiver.constructor.name)) {
182
- const commaSeparated = types.slice();
183
- const lastType = commaSeparated.pop();
184
- const typesString = commaSeparated.length
185
- ? commaSeparated.join(", ") + " or " + lastType
186
- : lastType;
187
- throw new Error(`${matcherName} can be only used with ${typesString} object${types.length > 1 ? "s" : ""}`);
188
- }
189
- }
190
- exports.expectTypes = expectTypes;
191
- exports.windowsFilesystemFriendlyLength = 60;
192
- function trimLongString(s, length = 100) {
193
- if (s.length <= length)
194
- return s;
195
- const hash = (0, utils_1.calculateSha1)(s);
196
- const middle = `-${hash.substring(0, 5)}-`;
197
- const start = Math.floor((length - middle.length) / 2);
198
- const end = length - middle.length - start;
199
- return s.substring(0, start) + middle + s.slice(-end);
200
- }
201
- exports.trimLongString = trimLongString;
202
- function addSuffixToFilePath(filePath, suffix) {
203
- const ext = path_1.default.extname(filePath);
204
- const base = filePath.substring(0, filePath.length - ext.length);
205
- return base + suffix + ext;
206
- }
207
- exports.addSuffixToFilePath = addSuffixToFilePath;
208
- function sanitizeFilePathBeforeExtension(filePath) {
209
- const ext = path_1.default.extname(filePath);
210
- const base = filePath.substring(0, filePath.length - ext.length);
211
- return (0, utils_1.sanitizeForFilePath)(base) + ext;
212
- }
213
- exports.sanitizeFilePathBeforeExtension = sanitizeFilePathBeforeExtension;
214
- /**
215
- * Returns absolute path contained within parent directory.
216
- */
217
- function getContainedPath(parentPath, subPath = "") {
218
- const resolvedPath = path_1.default.resolve(parentPath, subPath);
219
- if (resolvedPath === parentPath ||
220
- resolvedPath.startsWith(parentPath + path_1.default.sep))
221
- return resolvedPath;
222
- return null;
223
- }
224
- exports.getContainedPath = getContainedPath;
225
- exports.debugTest = (0, utilsBundle_1.debug)("pw:test");
226
- exports.callLogText = utils_1.formatCallLog;
227
26
  const folderToPackageJsonPath = new Map();
228
27
  function getPackageJsonPath(folderPath) {
229
28
  const cached = folderToPackageJsonPath.get(folderPath);
@@ -286,66 +85,3 @@ async function normalizeAndSaveAttachment(outputPath, name, options = {}) {
286
85
  }
287
86
  }
288
87
  exports.normalizeAndSaveAttachment = normalizeAndSaveAttachment;
289
- function fileIsModule(file) {
290
- if (file.endsWith(".mjs") || file.endsWith(".mts"))
291
- return true;
292
- if (file.endsWith(".cjs") || file.endsWith(".cts"))
293
- return false;
294
- const folder = path_1.default.dirname(file);
295
- return folderIsModule(folder);
296
- }
297
- exports.fileIsModule = fileIsModule;
298
- function folderIsModule(folder) {
299
- const packageJsonPath = getPackageJsonPath(folder);
300
- if (!packageJsonPath)
301
- return false;
302
- // Rely on `require` internal caching logic.
303
- return require(packageJsonPath).type === "module";
304
- }
305
- // This follows the --moduleResolution=bundler strategy from tsc.
306
- // https://devblogs.microsoft.com/typescript/announcing-typescript-5-0-beta/#moduleresolution-bundler
307
- const kExtLookups = new Map([
308
- [".js", [".jsx", ".ts", ".tsx"]],
309
- [".jsx", [".tsx"]],
310
- [".cjs", [".cts"]],
311
- [".mjs", [".mts"]],
312
- ["", [".js", ".ts", ".jsx", ".tsx", ".cjs", ".mjs", ".cts", ".mts"]],
313
- ]);
314
- function resolveImportSpecifierExtension(resolved, isPathMapping, isESM) {
315
- if (fileExists(resolved))
316
- return resolved;
317
- for (const [ext, others] of kExtLookups) {
318
- if (!resolved.endsWith(ext))
319
- continue;
320
- for (const other of others) {
321
- const modified = resolved.substring(0, resolved.length - ext.length) + other;
322
- if (fileExists(modified))
323
- return modified;
324
- }
325
- break; // Do not try '' when a more specific extension like '.jsx' matched.
326
- }
327
- // After TypeScript path mapping, here's how directories with a `package.json` are resolved:
328
- // - `package.json#exports` is not respected
329
- // - `package.json#main` is respected only in CJS mode
330
- // - `index.js` default is respected only in CJS mode
331
- //
332
- // More info:
333
- // - https://www.typescriptlang.org/docs/handbook/modules/reference.html#paths-should-not-point-to-monorepo-packages-or-node_modules-packages
334
- // - https://www.typescriptlang.org/docs/handbook/modules/reference.html#directory-modules-index-file-resolution
335
- // - https://nodejs.org/dist/latest-v20.x/docs/api/modules.html#folders-as-modules
336
- const shouldNotResolveDirectory = isPathMapping && isESM;
337
- if (!shouldNotResolveDirectory && dirExists(resolved)) {
338
- // If we import a package, let Node.js figure out the correct import based on package.json.
339
- if (fileExists(path_1.default.join(resolved, "package.json")))
340
- return resolved;
341
- const dirImport = path_1.default.join(resolved, "index");
342
- return resolveImportSpecifierExtension(dirImport, isPathMapping, isESM);
343
- }
344
- }
345
- exports.resolveImportSpecifierExtension = resolveImportSpecifierExtension;
346
- function fileExists(resolved) {
347
- return fs_1.default.statSync(resolved, { throwIfNoEntry: false })?.isFile();
348
- }
349
- function dirExists(resolved) {
350
- return fs_1.default.statSync(resolved, { throwIfNoEntry: false })?.isDirectory();
351
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/playwright-utils",
3
- "version": "0.7.4",
3
+ "version": "0.7.6",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -1,2 +0,0 @@
1
- export type RawStack = string[];
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/reporter/types/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC"}
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });