|
1
|
"use strict"; |
|
2
|
var __create = Object.create; |
|
3
|
var __defProp = Object.defineProperty; |
|
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
|
5
|
var __getOwnPropNames = Object.getOwnPropertyNames; |
|
6
|
var __getProtoOf = Object.getPrototypeOf; |
|
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty; |
|
8
|
var __export = (target, all) => { |
|
9
|
for (var name in all) |
|
10
|
__defProp(target, name, { get: all[name], enumerable: true }); |
|
11
|
}; |
|
12
|
var __copyProps = (to, from, except, desc) => { |
|
13
|
if (from && typeof from === "object" || typeof from === "function") { |
|
14
|
for (let key of __getOwnPropNames(from)) |
|
15
|
if (!__hasOwnProp.call(to, key) && key !== except) |
|
16
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); |
|
17
|
} |
|
18
|
return to; |
|
19
|
}; |
|
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( |
|
21
|
// If the importer is in node compatibility mode or this is not an ESM |
|
22
|
// file that has been converted to a CommonJS file using a Babel- |
|
23
|
// compatible transform (i.e. "__esModule" has not been set), then set |
|
24
|
// "default" to the CommonJS "module.exports" for node compatibility. |
|
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, |
|
26
|
mod |
|
27
|
)); |
|
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); |
|
29
|
var lastRun_exports = {}; |
|
30
|
__export(lastRun_exports, { |
|
31
|
LastRunReporter: () => LastRunReporter |
|
32
|
}); |
|
33
|
module.exports = __toCommonJS(lastRun_exports); |
|
34
|
var import_fs = __toESM(require("fs")); |
|
35
|
var import_path = __toESM(require("path")); |
|
36
|
var import_projectUtils = require("./projectUtils"); |
|
37
|
class LastRunReporter { |
|
38
|
constructor(config) { |
|
39
|
this._config = config; |
|
40
|
const [project] = (0, import_projectUtils.filterProjects)(config.projects, config.cliProjectFilter); |
|
41
|
if (project) |
|
42
|
this._lastRunFile = import_path.default.join(project.project.outputDir, ".last-run.json"); |
|
43
|
} |
|
44
|
async filterLastFailed() { |
|
45
|
if (!this._lastRunFile) |
|
46
|
return; |
|
47
|
try { |
|
48
|
const lastRunInfo = JSON.parse(await import_fs.default.promises.readFile(this._lastRunFile, "utf8")); |
|
49
|
const failedTestIds = new Set(lastRunInfo.failedTests); |
|
50
|
this._config.postShardTestFilters.push((test) => failedTestIds.has(test.id)); |
|
51
|
} catch { |
|
52
|
} |
|
53
|
} |
|
54
|
version() { |
|
55
|
return "v2"; |
|
56
|
} |
|
57
|
printsToStdio() { |
|
58
|
return false; |
|
59
|
} |
|
60
|
onBegin(suite) { |
|
61
|
this._suite = suite; |
|
62
|
} |
|
63
|
async onEnd(result) { |
|
64
|
if (!this._lastRunFile || this._config.cliListOnly) |
|
65
|
return; |
|
66
|
const lastRunInfo = { |
|
67
|
status: result.status, |
|
68
|
failedTests: this._suite?.allTests().filter((t) => !t.ok()).map((t) => t.id) || [] |
|
69
|
}; |
|
70
|
await import_fs.default.promises.mkdir(import_path.default.dirname(this._lastRunFile), { recursive: true }); |
|
71
|
await import_fs.default.promises.writeFile(this._lastRunFile, JSON.stringify(lastRunInfo, void 0, 2)); |
|
72
|
} |
|
73
|
} |
|
74
|
// Annotate the CommonJS export names for ESM import in node: |
|
75
|
0 && (module.exports = { |
|
76
|
LastRunReporter |
|
77
|
}); |
|
78
|
|