@empiricalrun/playwright-utils 0.6.3 → 0.7.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/CHANGELOG.md +12 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +4 -2
- package/dist/reporter/base.d.ts +67 -0
- package/dist/reporter/base.d.ts.map +1 -0
- package/dist/reporter/base.js +350 -0
- package/dist/reporter/custom.d.ts +68 -0
- package/dist/reporter/custom.d.ts.map +1 -0
- package/dist/reporter/custom.js +699 -0
- package/dist/reporter/reporterV2.d.ts +36 -0
- package/dist/reporter/reporterV2.d.ts.map +1 -0
- package/dist/reporter/reporterV2.js +98 -0
- package/dist/reporter/types/htmlReporter.d.ts +106 -0
- package/dist/reporter/types/htmlReporter.d.ts.map +1 -0
- package/dist/reporter/types/htmlReporter.js +17 -0
- package/dist/reporter/types/index.d.ts +2 -0
- package/dist/reporter/types/index.d.ts.map +1 -0
- package/dist/reporter/types/index.js +2 -0
- package/dist/reporter/upload.d.ts +11 -0
- package/dist/reporter/upload.d.ts.map +1 -0
- package/dist/reporter/upload.js +139 -0
- package/dist/reporter/util.d.ts +74 -0
- package/dist/reporter/util.d.ts.map +1 -0
- package/dist/reporter/util.js +351 -0
- package/package.json +18 -9
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/// <reference types="node" />
|
|
17
|
+
import type { FullConfig, FullResult, Reporter, Suite, TestCase, TestError, TestResult, TestStep } from "@playwright/test/reporter";
|
|
18
|
+
export interface ReporterV2 {
|
|
19
|
+
onConfigure(config: FullConfig): void;
|
|
20
|
+
onBegin(suite: Suite): void;
|
|
21
|
+
onTestBegin(test: TestCase, result: TestResult): void;
|
|
22
|
+
onStdOut(chunk: string | Buffer, test?: TestCase, result?: TestResult): void;
|
|
23
|
+
onStdErr(chunk: string | Buffer, test?: TestCase, result?: TestResult): void;
|
|
24
|
+
onTestEnd(test: TestCase, result: TestResult): void;
|
|
25
|
+
onEnd(result: FullResult): Promise<{
|
|
26
|
+
status?: FullResult["status"];
|
|
27
|
+
} | undefined | void> | void;
|
|
28
|
+
onExit(): void | Promise<void>;
|
|
29
|
+
onError(error: TestError): void;
|
|
30
|
+
onStepBegin(test: TestCase, result: TestResult, step: TestStep): void;
|
|
31
|
+
onStepEnd(test: TestCase, result: TestResult, step: TestStep): void;
|
|
32
|
+
printsToStdio(): boolean;
|
|
33
|
+
version(): "v2";
|
|
34
|
+
}
|
|
35
|
+
export declare function wrapReporterAsV2(reporter: Reporter | ReporterV2): ReporterV2;
|
|
36
|
+
//# sourceMappingURL=reporterV2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reporterV2.d.ts","sourceRoot":"","sources":["../../src/reporter/reporterV2.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;AAEH,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,SAAS,EACT,UAAU,EACV,QAAQ,EACT,MAAM,2BAA2B,CAAC;AAEnC,MAAM,WAAW,UAAU;IACzB,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IACtC,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CA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this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.wrapReporterAsV2 = void 0;
|
|
19
|
+
function wrapReporterAsV2(reporter) {
|
|
20
|
+
try {
|
|
21
|
+
if ("version" in reporter && reporter.version() === "v2")
|
|
22
|
+
return reporter;
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
console.log("reporter", reporter);
|
|
26
|
+
}
|
|
27
|
+
return new ReporterV2Wrapper(reporter);
|
|
28
|
+
}
|
|
29
|
+
exports.wrapReporterAsV2 = wrapReporterAsV2;
|
|
30
|
+
class ReporterV2Wrapper {
|
|
31
|
+
_reporter;
|
|
32
|
+
_deferred = [];
|
|
33
|
+
_config;
|
|
34
|
+
constructor(reporter) {
|
|
35
|
+
this._reporter = reporter;
|
|
36
|
+
}
|
|
37
|
+
version() {
|
|
38
|
+
return "v2";
|
|
39
|
+
}
|
|
40
|
+
onConfigure(config) {
|
|
41
|
+
this._config = config;
|
|
42
|
+
}
|
|
43
|
+
onBegin(suite) {
|
|
44
|
+
this._reporter.onBegin?.(this._config, suite);
|
|
45
|
+
const deferred = this._deferred;
|
|
46
|
+
this._deferred = null;
|
|
47
|
+
for (const item of deferred) {
|
|
48
|
+
if (item.error)
|
|
49
|
+
this.onError(item.error);
|
|
50
|
+
if (item.stdout)
|
|
51
|
+
this.onStdOut(item.stdout.chunk, item.stdout.test, item.stdout.result);
|
|
52
|
+
if (item.stderr)
|
|
53
|
+
this.onStdErr(item.stderr.chunk, item.stderr.test, item.stderr.result);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
onTestBegin(test, result) {
|
|
57
|
+
this._reporter.onTestBegin?.(test, result);
|
|
58
|
+
}
|
|
59
|
+
onStdOut(chunk, test, result) {
|
|
60
|
+
if (this._deferred) {
|
|
61
|
+
this._deferred.push({ stdout: { chunk, test, result } });
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
this._reporter.onStdOut?.(chunk, test, result);
|
|
65
|
+
}
|
|
66
|
+
onStdErr(chunk, test, result) {
|
|
67
|
+
if (this._deferred) {
|
|
68
|
+
this._deferred.push({ stderr: { chunk, test, result } });
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
this._reporter.onStdErr?.(chunk, test, result);
|
|
72
|
+
}
|
|
73
|
+
async onTestEnd(test, result) {
|
|
74
|
+
this._reporter.onTestEnd?.(test, result);
|
|
75
|
+
}
|
|
76
|
+
async onEnd(result) {
|
|
77
|
+
return await this._reporter.onEnd?.(result);
|
|
78
|
+
}
|
|
79
|
+
async onExit() {
|
|
80
|
+
await this._reporter.onExit?.();
|
|
81
|
+
}
|
|
82
|
+
onError(error) {
|
|
83
|
+
if (this._deferred) {
|
|
84
|
+
this._deferred.push({ error });
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
this._reporter.onError?.(error);
|
|
88
|
+
}
|
|
89
|
+
onStepBegin(test, result, step) {
|
|
90
|
+
this._reporter.onStepBegin?.(test, result, step);
|
|
91
|
+
}
|
|
92
|
+
onStepEnd(test, result, step) {
|
|
93
|
+
this._reporter.onStepEnd?.(test, result, step);
|
|
94
|
+
}
|
|
95
|
+
printsToStdio() {
|
|
96
|
+
return this._reporter.printsToStdio ? this._reporter.printsToStdio() : true;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import type { Metadata } from "@playwright/test";
|
|
17
|
+
export type Stats = {
|
|
18
|
+
total: number;
|
|
19
|
+
expected: number;
|
|
20
|
+
unexpected: number;
|
|
21
|
+
flaky: number;
|
|
22
|
+
skipped: number;
|
|
23
|
+
ok: boolean;
|
|
24
|
+
};
|
|
25
|
+
export type FilteredStats = {
|
|
26
|
+
total: number;
|
|
27
|
+
duration: number;
|
|
28
|
+
};
|
|
29
|
+
export type Location = {
|
|
30
|
+
file: string;
|
|
31
|
+
line: number;
|
|
32
|
+
column: number;
|
|
33
|
+
};
|
|
34
|
+
export type HTMLReport = {
|
|
35
|
+
metadata: Metadata;
|
|
36
|
+
files: TestFileSummary[];
|
|
37
|
+
stats: Stats;
|
|
38
|
+
projectNames: string[];
|
|
39
|
+
startTime: number;
|
|
40
|
+
duration: number;
|
|
41
|
+
errors: string[];
|
|
42
|
+
};
|
|
43
|
+
export type TestFile = {
|
|
44
|
+
fileId: string;
|
|
45
|
+
fileName: string;
|
|
46
|
+
tests: TestCase[];
|
|
47
|
+
};
|
|
48
|
+
export type TestFileSummary = {
|
|
49
|
+
fileId: string;
|
|
50
|
+
fileName: string;
|
|
51
|
+
tests: TestCaseSummary[];
|
|
52
|
+
stats: Stats;
|
|
53
|
+
};
|
|
54
|
+
export type TestCaseAnnotation = {
|
|
55
|
+
type: string;
|
|
56
|
+
description?: string;
|
|
57
|
+
};
|
|
58
|
+
export type TestCaseSummary = {
|
|
59
|
+
testId: string;
|
|
60
|
+
title: string;
|
|
61
|
+
path: string[];
|
|
62
|
+
projectName: string;
|
|
63
|
+
location: Location;
|
|
64
|
+
annotations: TestCaseAnnotation[];
|
|
65
|
+
tags: string[];
|
|
66
|
+
outcome: "skipped" | "expected" | "unexpected" | "flaky";
|
|
67
|
+
duration: number;
|
|
68
|
+
ok: boolean;
|
|
69
|
+
results: TestResultSummary[];
|
|
70
|
+
};
|
|
71
|
+
export type TestResultSummary = {
|
|
72
|
+
attachments: {
|
|
73
|
+
name: string;
|
|
74
|
+
contentType: string;
|
|
75
|
+
path?: string;
|
|
76
|
+
}[];
|
|
77
|
+
};
|
|
78
|
+
export type TestCase = Omit<TestCaseSummary, "results"> & {
|
|
79
|
+
results: TestResult[];
|
|
80
|
+
};
|
|
81
|
+
export type TestAttachment = {
|
|
82
|
+
name: string;
|
|
83
|
+
body?: string;
|
|
84
|
+
path?: string;
|
|
85
|
+
contentType: string;
|
|
86
|
+
};
|
|
87
|
+
export type TestResult = {
|
|
88
|
+
retry: number;
|
|
89
|
+
startTime: string;
|
|
90
|
+
duration: number;
|
|
91
|
+
steps: TestStep[];
|
|
92
|
+
errors: string[];
|
|
93
|
+
attachments: TestAttachment[];
|
|
94
|
+
status: "passed" | "failed" | "timedOut" | "skipped" | "interrupted";
|
|
95
|
+
};
|
|
96
|
+
export type TestStep = {
|
|
97
|
+
title: string;
|
|
98
|
+
startTime: string;
|
|
99
|
+
duration: number;
|
|
100
|
+
location?: Location;
|
|
101
|
+
snippet?: string;
|
|
102
|
+
error?: string;
|
|
103
|
+
steps: TestStep[];
|
|
104
|
+
count: number;
|
|
105
|
+
};
|
|
106
|
+
//# sourceMappingURL=htmlReporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"htmlReporter.d.ts","sourceRoot":"","sources":["../../../src/reporter/types/htmlReporter.ts"],"names":[],"mappings":"AAAA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AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/reporter/types/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface FileMap {
|
|
2
|
+
[file: string]: string;
|
|
3
|
+
}
|
|
4
|
+
export declare function uploadDirectory({ sourceDir, fileList, destinationDir, uploadBucket, }: {
|
|
5
|
+
sourceDir: string;
|
|
6
|
+
fileList?: string[];
|
|
7
|
+
destinationDir: string;
|
|
8
|
+
uploadBucket: string;
|
|
9
|
+
}): Promise<FileMap>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=upload.d.ts.map
|
|
@@ -0,0 +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;AA8GD,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"}
|
|
@@ -0,0 +1,139 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.uploadDirectory = void 0;
|
|
30
|
+
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
31
|
+
const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
|
|
32
|
+
const fs = __importStar(require("fs"));
|
|
33
|
+
const md5_1 = __importDefault(require("md5"));
|
|
34
|
+
const path_1 = __importDefault(require("path"));
|
|
35
|
+
const getFileList = (dir) => {
|
|
36
|
+
let files = [];
|
|
37
|
+
const items = fs.readdirSync(dir, {
|
|
38
|
+
withFileTypes: true,
|
|
39
|
+
});
|
|
40
|
+
for (const item of items) {
|
|
41
|
+
const isDir = item.isDirectory();
|
|
42
|
+
const absolutePath = `${dir}/${item.name}`;
|
|
43
|
+
if (isDir) {
|
|
44
|
+
files = [...files, ...getFileList(absolutePath)];
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
files.push(absolutePath);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return files;
|
|
51
|
+
};
|
|
52
|
+
const run = async (config) => {
|
|
53
|
+
const map = new Map();
|
|
54
|
+
const urls = {};
|
|
55
|
+
const S3 = new client_s3_1.S3Client({
|
|
56
|
+
region: "auto",
|
|
57
|
+
endpoint: `https://${config.accountId}.r2.cloudflarestorage.com`,
|
|
58
|
+
credentials: {
|
|
59
|
+
accessKeyId: config.accessKeyId,
|
|
60
|
+
secretAccessKey: config.secretAccessKey,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
let files;
|
|
64
|
+
if (config.fileList) {
|
|
65
|
+
files = config.fileList;
|
|
66
|
+
// console.log("fileList", files);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
files = getFileList(config.sourceDir);
|
|
70
|
+
// console.log("files", files);
|
|
71
|
+
}
|
|
72
|
+
await Promise.all(files.map(async (file) => {
|
|
73
|
+
// console.log(file);
|
|
74
|
+
const fileStream = fs.readFileSync(file);
|
|
75
|
+
// console.log(config.sourceDir);
|
|
76
|
+
// console.log(config.destinationDir);
|
|
77
|
+
//const fileName = file.replace(/^.*[\\\/]/, "");
|
|
78
|
+
const fileName = file.replace(config.sourceDir, "");
|
|
79
|
+
const fileKey = path_1.default.join(config.destinationDir !== "" ? config.destinationDir : config.sourceDir, fileName);
|
|
80
|
+
if (fileKey.includes(".gitkeep"))
|
|
81
|
+
return;
|
|
82
|
+
// console.log(fileKey);
|
|
83
|
+
let mimeType = "application/octet-stream";
|
|
84
|
+
try {
|
|
85
|
+
const mime = (await import("mime")).default;
|
|
86
|
+
mimeType = mime.getType(file) || "application/octet-stream";
|
|
87
|
+
}
|
|
88
|
+
catch (err) {
|
|
89
|
+
console.warn("Failed to get mime type for file", file, err);
|
|
90
|
+
}
|
|
91
|
+
const uploadParams = {
|
|
92
|
+
Bucket: config.bucket,
|
|
93
|
+
Key: fileKey,
|
|
94
|
+
Body: fileStream,
|
|
95
|
+
ContentLength: fs.statSync(file).size,
|
|
96
|
+
ContentType: mimeType ?? "application/octet-stream",
|
|
97
|
+
};
|
|
98
|
+
const cmd = new client_s3_1.PutObjectCommand(uploadParams);
|
|
99
|
+
const digest = (0, md5_1.default)(fileStream);
|
|
100
|
+
cmd.middlewareStack.add((next) => async (args) => {
|
|
101
|
+
args.request.headers["if-none-match"] = `"${digest}"`;
|
|
102
|
+
return await next(args);
|
|
103
|
+
}, {
|
|
104
|
+
step: "build",
|
|
105
|
+
name: "addETag",
|
|
106
|
+
});
|
|
107
|
+
try {
|
|
108
|
+
const data = await S3.send(cmd);
|
|
109
|
+
console.log(`R2 Success - for sourceDir: ${config.sourceDir} destinationDir: ${config.destinationDir} bucket: ${config.bucket} ${config.fileList ? config.fileList : ""}`);
|
|
110
|
+
map.set(file, data);
|
|
111
|
+
const fileUrl = await (0, s3_request_presigner_1.getSignedUrl)(S3, cmd);
|
|
112
|
+
urls[file] = fileUrl;
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
const error = err;
|
|
116
|
+
if (error["$metadata"]) {
|
|
117
|
+
if (error.$metadata.httpStatusCode !== 412)
|
|
118
|
+
// If-None-Match
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return;
|
|
123
|
+
}));
|
|
124
|
+
return urls;
|
|
125
|
+
};
|
|
126
|
+
async function uploadDirectory({ sourceDir, fileList, destinationDir, uploadBucket, }) {
|
|
127
|
+
let config = {
|
|
128
|
+
accountId: process.env.R2_ACCOUNT_ID,
|
|
129
|
+
accessKeyId: process.env.R2_ACCESS_KEY_ID,
|
|
130
|
+
secretAccessKey: process.env.R2_SECRET_ACCESS_KEY,
|
|
131
|
+
bucket: uploadBucket,
|
|
132
|
+
sourceDir,
|
|
133
|
+
destinationDir,
|
|
134
|
+
fileList,
|
|
135
|
+
};
|
|
136
|
+
const uploadedFiles = await run(config);
|
|
137
|
+
return uploadedFiles;
|
|
138
|
+
}
|
|
139
|
+
exports.uploadDirectory = uploadDirectory;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
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
|
+
export declare function getPackageJsonPath(folderPath: string): string;
|
|
61
|
+
export declare function resolveReporterOutputPath(defaultValue: string, configDir: string, configValue: string | undefined): string;
|
|
62
|
+
export declare function normalizeAndSaveAttachment(outputPath: string, name: string, options?: {
|
|
63
|
+
path?: string;
|
|
64
|
+
body?: string | Buffer;
|
|
65
|
+
contentType?: string;
|
|
66
|
+
}): Promise<{
|
|
67
|
+
name: string;
|
|
68
|
+
path?: string | undefined;
|
|
69
|
+
body?: Buffer | undefined;
|
|
70
|
+
contentType: string;
|
|
71
|
+
}>;
|
|
72
|
+
export declare function fileIsModule(file: string): boolean;
|
|
73
|
+
export declare function resolveImportSpecifierExtension(resolved: string, isPathMapping: boolean, isESM: boolean): string | undefined;
|
|
74
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +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;IAC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