|
f7eb47b…
|
lmata
|
1 |
"use strict"; |
|
f7eb47b…
|
lmata
|
2 |
var __create = Object.create; |
|
f7eb47b…
|
lmata
|
3 |
var __defProp = Object.defineProperty; |
|
f7eb47b…
|
lmata
|
4 |
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
|
f7eb47b…
|
lmata
|
5 |
var __getOwnPropNames = Object.getOwnPropertyNames; |
|
f7eb47b…
|
lmata
|
6 |
var __getProtoOf = Object.getPrototypeOf; |
|
f7eb47b…
|
lmata
|
7 |
var __hasOwnProp = Object.prototype.hasOwnProperty; |
|
f7eb47b…
|
lmata
|
8 |
var __export = (target, all) => { |
|
f7eb47b…
|
lmata
|
9 |
for (var name in all) |
|
f7eb47b…
|
lmata
|
10 |
__defProp(target, name, { get: all[name], enumerable: true }); |
|
f7eb47b…
|
lmata
|
11 |
}; |
|
f7eb47b…
|
lmata
|
12 |
var __copyProps = (to, from, except, desc) => { |
|
f7eb47b…
|
lmata
|
13 |
if (from && typeof from === "object" || typeof from === "function") { |
|
f7eb47b…
|
lmata
|
14 |
for (let key of __getOwnPropNames(from)) |
|
f7eb47b…
|
lmata
|
15 |
if (!__hasOwnProp.call(to, key) && key !== except) |
|
f7eb47b…
|
lmata
|
16 |
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); |
|
f7eb47b…
|
lmata
|
17 |
} |
|
f7eb47b…
|
lmata
|
18 |
return to; |
|
f7eb47b…
|
lmata
|
19 |
}; |
|
f7eb47b…
|
lmata
|
20 |
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( |
|
f7eb47b…
|
lmata
|
21 |
// If the importer is in node compatibility mode or this is not an ESM |
|
f7eb47b…
|
lmata
|
22 |
// file that has been converted to a CommonJS file using a Babel- |
|
f7eb47b…
|
lmata
|
23 |
// compatible transform (i.e. "__esModule" has not been set), then set |
|
f7eb47b…
|
lmata
|
24 |
// "default" to the CommonJS "module.exports" for node compatibility. |
|
f7eb47b…
|
lmata
|
25 |
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, |
|
f7eb47b…
|
lmata
|
26 |
mod |
|
f7eb47b…
|
lmata
|
27 |
)); |
|
f7eb47b…
|
lmata
|
28 |
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); |
|
f7eb47b…
|
lmata
|
29 |
var tasks_exports = {}; |
|
f7eb47b…
|
lmata
|
30 |
__export(tasks_exports, { |
|
f7eb47b…
|
lmata
|
31 |
TestRun: () => TestRun, |
|
f7eb47b…
|
lmata
|
32 |
createApplyRebaselinesTask: () => createApplyRebaselinesTask, |
|
f7eb47b…
|
lmata
|
33 |
createClearCacheTask: () => createClearCacheTask, |
|
f7eb47b…
|
lmata
|
34 |
createGlobalSetupTasks: () => createGlobalSetupTasks, |
|
f7eb47b…
|
lmata
|
35 |
createListFilesTask: () => createListFilesTask, |
|
f7eb47b…
|
lmata
|
36 |
createLoadTask: () => createLoadTask, |
|
f7eb47b…
|
lmata
|
37 |
createPluginSetupTasks: () => createPluginSetupTasks, |
|
f7eb47b…
|
lmata
|
38 |
createReportBeginTask: () => createReportBeginTask, |
|
f7eb47b…
|
lmata
|
39 |
createRunTestsTasks: () => createRunTestsTasks, |
|
f7eb47b…
|
lmata
|
40 |
createStartDevServerTask: () => createStartDevServerTask, |
|
f7eb47b…
|
lmata
|
41 |
runTasks: () => runTasks, |
|
f7eb47b…
|
lmata
|
42 |
runTasksDeferCleanup: () => runTasksDeferCleanup |
|
f7eb47b…
|
lmata
|
43 |
}); |
|
f7eb47b…
|
lmata
|
44 |
module.exports = __toCommonJS(tasks_exports); |
|
f7eb47b…
|
lmata
|
45 |
var import_fs = __toESM(require("fs")); |
|
f7eb47b…
|
lmata
|
46 |
var import_path = __toESM(require("path")); |
|
f7eb47b…
|
lmata
|
47 |
var import_util = require("util"); |
|
f7eb47b…
|
lmata
|
48 |
var import_utils = require("playwright-core/lib/utils"); |
|
f7eb47b…
|
lmata
|
49 |
var import_utilsBundle = require("playwright-core/lib/utilsBundle"); |
|
f7eb47b…
|
lmata
|
50 |
var import_dispatcher = require("./dispatcher"); |
|
f7eb47b…
|
lmata
|
51 |
var import_failureTracker = require("./failureTracker"); |
|
f7eb47b…
|
lmata
|
52 |
var import_loadUtils = require("./loadUtils"); |
|
f7eb47b…
|
lmata
|
53 |
var import_projectUtils = require("./projectUtils"); |
|
f7eb47b…
|
lmata
|
54 |
var import_rebase = require("./rebase"); |
|
f7eb47b…
|
lmata
|
55 |
var import_taskRunner = require("./taskRunner"); |
|
f7eb47b…
|
lmata
|
56 |
var import_vcs = require("./vcs"); |
|
f7eb47b…
|
lmata
|
57 |
var import_test = require("../common/test"); |
|
f7eb47b…
|
lmata
|
58 |
var import_testGroups = require("../runner/testGroups"); |
|
f7eb47b…
|
lmata
|
59 |
var import_compilationCache = require("../transform/compilationCache"); |
|
f7eb47b…
|
lmata
|
60 |
var import_util2 = require("../util"); |
|
f7eb47b…
|
lmata
|
61 |
const readDirAsync = (0, import_util.promisify)(import_fs.default.readdir); |
|
f7eb47b…
|
lmata
|
62 |
class TestRun { |
|
f7eb47b…
|
lmata
|
63 |
constructor(config, reporter, options) { |
|
f7eb47b…
|
lmata
|
64 |
this.rootSuite = void 0; |
|
f7eb47b…
|
lmata
|
65 |
this.phases = []; |
|
f7eb47b…
|
lmata
|
66 |
this.projectFiles = /* @__PURE__ */ new Map(); |
|
f7eb47b…
|
lmata
|
67 |
this.projectSuites = /* @__PURE__ */ new Map(); |
|
f7eb47b…
|
lmata
|
68 |
this.topLevelProjects = []; |
|
f7eb47b…
|
lmata
|
69 |
this.config = config; |
|
f7eb47b…
|
lmata
|
70 |
this.reporter = reporter; |
|
f7eb47b…
|
lmata
|
71 |
this.failureTracker = new import_failureTracker.FailureTracker(config, options); |
|
f7eb47b…
|
lmata
|
72 |
} |
|
f7eb47b…
|
lmata
|
73 |
} |
|
f7eb47b…
|
lmata
|
74 |
async function runTasks(testRun, tasks, globalTimeout, cancelPromise) { |
|
f7eb47b…
|
lmata
|
75 |
const deadline = globalTimeout ? (0, import_utils.monotonicTime)() + globalTimeout : 0; |
|
f7eb47b…
|
lmata
|
76 |
const taskRunner = new import_taskRunner.TaskRunner(testRun.reporter, globalTimeout || 0); |
|
f7eb47b…
|
lmata
|
77 |
for (const task of tasks) |
|
f7eb47b…
|
lmata
|
78 |
taskRunner.addTask(task); |
|
f7eb47b…
|
lmata
|
79 |
testRun.reporter.onConfigure(testRun.config.config); |
|
f7eb47b…
|
lmata
|
80 |
const status = await taskRunner.run(testRun, deadline, cancelPromise); |
|
f7eb47b…
|
lmata
|
81 |
return await finishTaskRun(testRun, status); |
|
f7eb47b…
|
lmata
|
82 |
} |
|
f7eb47b…
|
lmata
|
83 |
async function runTasksDeferCleanup(testRun, tasks) { |
|
f7eb47b…
|
lmata
|
84 |
const taskRunner = new import_taskRunner.TaskRunner(testRun.reporter, 0); |
|
f7eb47b…
|
lmata
|
85 |
for (const task of tasks) |
|
f7eb47b…
|
lmata
|
86 |
taskRunner.addTask(task); |
|
f7eb47b…
|
lmata
|
87 |
testRun.reporter.onConfigure(testRun.config.config); |
|
f7eb47b…
|
lmata
|
88 |
const { status, cleanup } = await taskRunner.runDeferCleanup(testRun, 0); |
|
f7eb47b…
|
lmata
|
89 |
return { status: await finishTaskRun(testRun, status), cleanup }; |
|
f7eb47b…
|
lmata
|
90 |
} |
|
f7eb47b…
|
lmata
|
91 |
async function finishTaskRun(testRun, status) { |
|
f7eb47b…
|
lmata
|
92 |
if (status === "passed") |
|
f7eb47b…
|
lmata
|
93 |
status = testRun.failureTracker.result(); |
|
f7eb47b…
|
lmata
|
94 |
const modifiedResult = await testRun.reporter.onEnd({ status }); |
|
f7eb47b…
|
lmata
|
95 |
if (modifiedResult && modifiedResult.status) |
|
f7eb47b…
|
lmata
|
96 |
status = modifiedResult.status; |
|
f7eb47b…
|
lmata
|
97 |
await testRun.reporter.onExit(); |
|
f7eb47b…
|
lmata
|
98 |
return status; |
|
f7eb47b…
|
lmata
|
99 |
} |
|
f7eb47b…
|
lmata
|
100 |
function createGlobalSetupTasks(config) { |
|
f7eb47b…
|
lmata
|
101 |
const tasks = []; |
|
f7eb47b…
|
lmata
|
102 |
if (!config.configCLIOverrides.preserveOutputDir) |
|
f7eb47b…
|
lmata
|
103 |
tasks.push(createRemoveOutputDirsTask()); |
|
f7eb47b…
|
lmata
|
104 |
tasks.push( |
|
f7eb47b…
|
lmata
|
105 |
...createPluginSetupTasks(config), |
|
f7eb47b…
|
lmata
|
106 |
...config.globalTeardowns.map((file) => createGlobalTeardownTask(file, config)).reverse(), |
|
f7eb47b…
|
lmata
|
107 |
...config.globalSetups.map((file) => createGlobalSetupTask(file, config)) |
|
f7eb47b…
|
lmata
|
108 |
); |
|
f7eb47b…
|
lmata
|
109 |
return tasks; |
|
f7eb47b…
|
lmata
|
110 |
} |
|
f7eb47b…
|
lmata
|
111 |
function createRunTestsTasks(config) { |
|
f7eb47b…
|
lmata
|
112 |
return [ |
|
f7eb47b…
|
lmata
|
113 |
createPhasesTask(), |
|
f7eb47b…
|
lmata
|
114 |
createReportBeginTask(), |
|
f7eb47b…
|
lmata
|
115 |
...config.plugins.map((plugin) => createPluginBeginTask(plugin)), |
|
f7eb47b…
|
lmata
|
116 |
createRunTestsTask() |
|
f7eb47b…
|
lmata
|
117 |
]; |
|
f7eb47b…
|
lmata
|
118 |
} |
|
f7eb47b…
|
lmata
|
119 |
function createClearCacheTask(config) { |
|
f7eb47b…
|
lmata
|
120 |
return { |
|
f7eb47b…
|
lmata
|
121 |
title: "clear cache", |
|
f7eb47b…
|
lmata
|
122 |
setup: async () => { |
|
f7eb47b…
|
lmata
|
123 |
await (0, import_util2.removeDirAndLogToConsole)(import_compilationCache.cacheDir); |
|
f7eb47b…
|
lmata
|
124 |
for (const plugin of config.plugins) |
|
f7eb47b…
|
lmata
|
125 |
await plugin.instance?.clearCache?.(); |
|
f7eb47b…
|
lmata
|
126 |
} |
|
f7eb47b…
|
lmata
|
127 |
}; |
|
f7eb47b…
|
lmata
|
128 |
} |
|
f7eb47b…
|
lmata
|
129 |
function createReportBeginTask() { |
|
f7eb47b…
|
lmata
|
130 |
return { |
|
f7eb47b…
|
lmata
|
131 |
title: "report begin", |
|
f7eb47b…
|
lmata
|
132 |
setup: async (testRun) => { |
|
f7eb47b…
|
lmata
|
133 |
testRun.reporter.onBegin?.(testRun.rootSuite); |
|
f7eb47b…
|
lmata
|
134 |
}, |
|
f7eb47b…
|
lmata
|
135 |
teardown: async ({}) => { |
|
f7eb47b…
|
lmata
|
136 |
} |
|
f7eb47b…
|
lmata
|
137 |
}; |
|
f7eb47b…
|
lmata
|
138 |
} |
|
f7eb47b…
|
lmata
|
139 |
function createPluginSetupTasks(config) { |
|
f7eb47b…
|
lmata
|
140 |
return config.plugins.map((plugin) => ({ |
|
f7eb47b…
|
lmata
|
141 |
title: "plugin setup", |
|
f7eb47b…
|
lmata
|
142 |
setup: async ({ reporter }) => { |
|
f7eb47b…
|
lmata
|
143 |
if (typeof plugin.factory === "function") |
|
f7eb47b…
|
lmata
|
144 |
plugin.instance = await plugin.factory(); |
|
f7eb47b…
|
lmata
|
145 |
else |
|
f7eb47b…
|
lmata
|
146 |
plugin.instance = plugin.factory; |
|
f7eb47b…
|
lmata
|
147 |
await plugin.instance?.setup?.(config.config, config.configDir, reporter); |
|
f7eb47b…
|
lmata
|
148 |
}, |
|
f7eb47b…
|
lmata
|
149 |
teardown: async () => { |
|
f7eb47b…
|
lmata
|
150 |
await plugin.instance?.teardown?.(); |
|
f7eb47b…
|
lmata
|
151 |
} |
|
f7eb47b…
|
lmata
|
152 |
})); |
|
f7eb47b…
|
lmata
|
153 |
} |
|
f7eb47b…
|
lmata
|
154 |
function createPluginBeginTask(plugin) { |
|
f7eb47b…
|
lmata
|
155 |
return { |
|
f7eb47b…
|
lmata
|
156 |
title: "plugin begin", |
|
f7eb47b…
|
lmata
|
157 |
setup: async (testRun) => { |
|
f7eb47b…
|
lmata
|
158 |
await plugin.instance?.begin?.(testRun.rootSuite); |
|
f7eb47b…
|
lmata
|
159 |
}, |
|
f7eb47b…
|
lmata
|
160 |
teardown: async () => { |
|
f7eb47b…
|
lmata
|
161 |
await plugin.instance?.end?.(); |
|
f7eb47b…
|
lmata
|
162 |
} |
|
f7eb47b…
|
lmata
|
163 |
}; |
|
f7eb47b…
|
lmata
|
164 |
} |
|
f7eb47b…
|
lmata
|
165 |
function createGlobalSetupTask(file, config) { |
|
f7eb47b…
|
lmata
|
166 |
let title = "global setup"; |
|
f7eb47b…
|
lmata
|
167 |
if (config.globalSetups.length > 1) |
|
f7eb47b…
|
lmata
|
168 |
title += ` (${file})`; |
|
f7eb47b…
|
lmata
|
169 |
let globalSetupResult; |
|
f7eb47b…
|
lmata
|
170 |
return { |
|
f7eb47b…
|
lmata
|
171 |
title, |
|
f7eb47b…
|
lmata
|
172 |
setup: async ({ config: config2 }) => { |
|
f7eb47b…
|
lmata
|
173 |
const setupHook = await (0, import_loadUtils.loadGlobalHook)(config2, file); |
|
f7eb47b…
|
lmata
|
174 |
globalSetupResult = await setupHook(config2.config); |
|
f7eb47b…
|
lmata
|
175 |
}, |
|
f7eb47b…
|
lmata
|
176 |
teardown: async () => { |
|
f7eb47b…
|
lmata
|
177 |
if (typeof globalSetupResult === "function") |
|
f7eb47b…
|
lmata
|
178 |
await globalSetupResult(); |
|
f7eb47b…
|
lmata
|
179 |
} |
|
f7eb47b…
|
lmata
|
180 |
}; |
|
f7eb47b…
|
lmata
|
181 |
} |
|
f7eb47b…
|
lmata
|
182 |
function createGlobalTeardownTask(file, config) { |
|
f7eb47b…
|
lmata
|
183 |
let title = "global teardown"; |
|
f7eb47b…
|
lmata
|
184 |
if (config.globalTeardowns.length > 1) |
|
f7eb47b…
|
lmata
|
185 |
title += ` (${file})`; |
|
f7eb47b…
|
lmata
|
186 |
return { |
|
f7eb47b…
|
lmata
|
187 |
title, |
|
f7eb47b…
|
lmata
|
188 |
teardown: async ({ config: config2 }) => { |
|
f7eb47b…
|
lmata
|
189 |
const teardownHook = await (0, import_loadUtils.loadGlobalHook)(config2, file); |
|
f7eb47b…
|
lmata
|
190 |
await teardownHook(config2.config); |
|
f7eb47b…
|
lmata
|
191 |
} |
|
f7eb47b…
|
lmata
|
192 |
}; |
|
f7eb47b…
|
lmata
|
193 |
} |
|
f7eb47b…
|
lmata
|
194 |
function createRemoveOutputDirsTask() { |
|
f7eb47b…
|
lmata
|
195 |
return { |
|
f7eb47b…
|
lmata
|
196 |
title: "clear output", |
|
f7eb47b…
|
lmata
|
197 |
setup: async ({ config }) => { |
|
f7eb47b…
|
lmata
|
198 |
const outputDirs = /* @__PURE__ */ new Set(); |
|
f7eb47b…
|
lmata
|
199 |
const projects = (0, import_projectUtils.filterProjects)(config.projects, config.cliProjectFilter); |
|
f7eb47b…
|
lmata
|
200 |
projects.forEach((p) => outputDirs.add(p.project.outputDir)); |
|
f7eb47b…
|
lmata
|
201 |
await Promise.all(Array.from(outputDirs).map((outputDir) => (0, import_utils.removeFolders)([outputDir]).then(async ([error]) => { |
|
f7eb47b…
|
lmata
|
202 |
if (!error) |
|
f7eb47b…
|
lmata
|
203 |
return; |
|
f7eb47b…
|
lmata
|
204 |
if (error.code === "EBUSY") { |
|
f7eb47b…
|
lmata
|
205 |
const entries = await readDirAsync(outputDir).catch((e) => []); |
|
f7eb47b…
|
lmata
|
206 |
await Promise.all(entries.map((entry) => (0, import_utils.removeFolders)([import_path.default.join(outputDir, entry)]))); |
|
f7eb47b…
|
lmata
|
207 |
} else { |
|
f7eb47b…
|
lmata
|
208 |
throw error; |
|
f7eb47b…
|
lmata
|
209 |
} |
|
f7eb47b…
|
lmata
|
210 |
}))); |
|
f7eb47b…
|
lmata
|
211 |
} |
|
f7eb47b…
|
lmata
|
212 |
}; |
|
f7eb47b…
|
lmata
|
213 |
} |
|
f7eb47b…
|
lmata
|
214 |
function createListFilesTask() { |
|
f7eb47b…
|
lmata
|
215 |
return { |
|
f7eb47b…
|
lmata
|
216 |
title: "load tests", |
|
f7eb47b…
|
lmata
|
217 |
setup: async (testRun, errors) => { |
|
f7eb47b…
|
lmata
|
218 |
const { rootSuite, topLevelProjects } = await (0, import_loadUtils.createRootSuite)(testRun, errors, false); |
|
f7eb47b…
|
lmata
|
219 |
testRun.rootSuite = rootSuite; |
|
f7eb47b…
|
lmata
|
220 |
testRun.failureTracker.onRootSuite(rootSuite, topLevelProjects); |
|
f7eb47b…
|
lmata
|
221 |
await (0, import_loadUtils.collectProjectsAndTestFiles)(testRun, false); |
|
f7eb47b…
|
lmata
|
222 |
for (const [project, files] of testRun.projectFiles) { |
|
f7eb47b…
|
lmata
|
223 |
const projectSuite = new import_test.Suite(project.project.name, "project"); |
|
f7eb47b…
|
lmata
|
224 |
projectSuite._fullProject = project; |
|
f7eb47b…
|
lmata
|
225 |
testRun.rootSuite._addSuite(projectSuite); |
|
f7eb47b…
|
lmata
|
226 |
const suites = files.map((file) => { |
|
f7eb47b…
|
lmata
|
227 |
const title = import_path.default.relative(testRun.config.config.rootDir, file); |
|
f7eb47b…
|
lmata
|
228 |
const suite = new import_test.Suite(title, "file"); |
|
f7eb47b…
|
lmata
|
229 |
suite.location = { file, line: 0, column: 0 }; |
|
f7eb47b…
|
lmata
|
230 |
projectSuite._addSuite(suite); |
|
f7eb47b…
|
lmata
|
231 |
return suite; |
|
f7eb47b…
|
lmata
|
232 |
}); |
|
f7eb47b…
|
lmata
|
233 |
testRun.projectSuites.set(project, suites); |
|
f7eb47b…
|
lmata
|
234 |
} |
|
f7eb47b…
|
lmata
|
235 |
} |
|
f7eb47b…
|
lmata
|
236 |
}; |
|
f7eb47b…
|
lmata
|
237 |
} |
|
f7eb47b…
|
lmata
|
238 |
function createLoadTask(mode, options) { |
|
f7eb47b…
|
lmata
|
239 |
return { |
|
f7eb47b…
|
lmata
|
240 |
title: "load tests", |
|
f7eb47b…
|
lmata
|
241 |
setup: async (testRun, errors, softErrors) => { |
|
f7eb47b…
|
lmata
|
242 |
await (0, import_loadUtils.collectProjectsAndTestFiles)(testRun, !!options.doNotRunDepsOutsideProjectFilter); |
|
f7eb47b…
|
lmata
|
243 |
await (0, import_loadUtils.loadFileSuites)(testRun, mode, options.failOnLoadErrors ? errors : softErrors); |
|
f7eb47b…
|
lmata
|
244 |
if (testRun.config.cliOnlyChanged || options.populateDependencies) { |
|
f7eb47b…
|
lmata
|
245 |
for (const plugin of testRun.config.plugins) |
|
f7eb47b…
|
lmata
|
246 |
await plugin.instance?.populateDependencies?.(); |
|
f7eb47b…
|
lmata
|
247 |
} |
|
f7eb47b…
|
lmata
|
248 |
if (testRun.config.cliOnlyChanged) { |
|
f7eb47b…
|
lmata
|
249 |
const changedFiles = await (0, import_vcs.detectChangedTestFiles)(testRun.config.cliOnlyChanged, testRun.config.configDir); |
|
f7eb47b…
|
lmata
|
250 |
testRun.config.preOnlyTestFilters.push((test) => changedFiles.has(test.location.file)); |
|
f7eb47b…
|
lmata
|
251 |
} |
|
f7eb47b…
|
lmata
|
252 |
if (testRun.config.cliTestList) { |
|
f7eb47b…
|
lmata
|
253 |
const testListFilter = await (0, import_loadUtils.loadTestList)(testRun.config, testRun.config.cliTestList); |
|
f7eb47b…
|
lmata
|
254 |
testRun.config.preOnlyTestFilters.push(testListFilter); |
|
f7eb47b…
|
lmata
|
255 |
} |
|
f7eb47b…
|
lmata
|
256 |
if (testRun.config.cliTestListInvert) { |
|
f7eb47b…
|
lmata
|
257 |
const testListInvertFilter = await (0, import_loadUtils.loadTestList)(testRun.config, testRun.config.cliTestListInvert); |
|
f7eb47b…
|
lmata
|
258 |
testRun.config.preOnlyTestFilters.push((test) => !testListInvertFilter(test)); |
|
f7eb47b…
|
lmata
|
259 |
} |
|
f7eb47b…
|
lmata
|
260 |
const { rootSuite, topLevelProjects } = await (0, import_loadUtils.createRootSuite)(testRun, options.failOnLoadErrors ? errors : softErrors, !!options.filterOnly); |
|
f7eb47b…
|
lmata
|
261 |
testRun.rootSuite = rootSuite; |
|
f7eb47b…
|
lmata
|
262 |
testRun.failureTracker.onRootSuite(rootSuite, topLevelProjects); |
|
f7eb47b…
|
lmata
|
263 |
if (options.failOnLoadErrors && !testRun.rootSuite.allTests().length && !testRun.config.cliPassWithNoTests && !testRun.config.config.shard && !testRun.config.cliOnlyChanged && !testRun.config.cliTestList && !testRun.config.cliTestListInvert) { |
|
f7eb47b…
|
lmata
|
264 |
if (testRun.config.cliArgs.length) { |
|
f7eb47b…
|
lmata
|
265 |
throw new Error([ |
|
f7eb47b…
|
lmata
|
266 |
`No tests found.`, |
|
f7eb47b…
|
lmata
|
267 |
`Make sure that arguments are regular expressions matching test files.`, |
|
f7eb47b…
|
lmata
|
268 |
`You may need to escape symbols like "$" or "*" and quote the arguments.` |
|
f7eb47b…
|
lmata
|
269 |
].join("\n")); |
|
f7eb47b…
|
lmata
|
270 |
} |
|
f7eb47b…
|
lmata
|
271 |
throw new Error(`No tests found`); |
|
f7eb47b…
|
lmata
|
272 |
} |
|
f7eb47b…
|
lmata
|
273 |
} |
|
f7eb47b…
|
lmata
|
274 |
}; |
|
f7eb47b…
|
lmata
|
275 |
} |
|
f7eb47b…
|
lmata
|
276 |
function createApplyRebaselinesTask() { |
|
f7eb47b…
|
lmata
|
277 |
return { |
|
f7eb47b…
|
lmata
|
278 |
title: "apply rebaselines", |
|
f7eb47b…
|
lmata
|
279 |
setup: async () => { |
|
f7eb47b…
|
lmata
|
280 |
(0, import_rebase.clearSuggestedRebaselines)(); |
|
f7eb47b…
|
lmata
|
281 |
}, |
|
f7eb47b…
|
lmata
|
282 |
teardown: async ({ config, reporter }) => { |
|
f7eb47b…
|
lmata
|
283 |
await (0, import_rebase.applySuggestedRebaselines)(config, reporter); |
|
f7eb47b…
|
lmata
|
284 |
} |
|
f7eb47b…
|
lmata
|
285 |
}; |
|
f7eb47b…
|
lmata
|
286 |
} |
|
f7eb47b…
|
lmata
|
287 |
function createPhasesTask() { |
|
f7eb47b…
|
lmata
|
288 |
return { |
|
f7eb47b…
|
lmata
|
289 |
title: "create phases", |
|
f7eb47b…
|
lmata
|
290 |
setup: async (testRun) => { |
|
f7eb47b…
|
lmata
|
291 |
let maxConcurrentTestGroups = 0; |
|
f7eb47b…
|
lmata
|
292 |
const processed = /* @__PURE__ */ new Set(); |
|
f7eb47b…
|
lmata
|
293 |
const projectToSuite = new Map(testRun.rootSuite.suites.map((suite) => [suite._fullProject, suite])); |
|
f7eb47b…
|
lmata
|
294 |
const allProjects = [...projectToSuite.keys()]; |
|
f7eb47b…
|
lmata
|
295 |
const teardownToSetups = (0, import_projectUtils.buildTeardownToSetupsMap)(allProjects); |
|
f7eb47b…
|
lmata
|
296 |
const teardownToSetupsDependents = /* @__PURE__ */ new Map(); |
|
f7eb47b…
|
lmata
|
297 |
for (const [teardown, setups] of teardownToSetups) { |
|
f7eb47b…
|
lmata
|
298 |
const closure = (0, import_projectUtils.buildDependentProjects)(setups, allProjects); |
|
f7eb47b…
|
lmata
|
299 |
closure.delete(teardown); |
|
f7eb47b…
|
lmata
|
300 |
teardownToSetupsDependents.set(teardown, [...closure]); |
|
f7eb47b…
|
lmata
|
301 |
} |
|
f7eb47b…
|
lmata
|
302 |
for (let i = 0; i < projectToSuite.size; i++) { |
|
f7eb47b…
|
lmata
|
303 |
const phaseProjects = []; |
|
f7eb47b…
|
lmata
|
304 |
for (const project of projectToSuite.keys()) { |
|
f7eb47b…
|
lmata
|
305 |
if (processed.has(project)) |
|
f7eb47b…
|
lmata
|
306 |
continue; |
|
f7eb47b…
|
lmata
|
307 |
const projectsThatShouldFinishFirst = [...project.deps, ...teardownToSetupsDependents.get(project) || []]; |
|
f7eb47b…
|
lmata
|
308 |
if (projectsThatShouldFinishFirst.find((p) => !processed.has(p))) |
|
f7eb47b…
|
lmata
|
309 |
continue; |
|
f7eb47b…
|
lmata
|
310 |
phaseProjects.push(project); |
|
f7eb47b…
|
lmata
|
311 |
} |
|
f7eb47b…
|
lmata
|
312 |
for (const project of phaseProjects) |
|
f7eb47b…
|
lmata
|
313 |
processed.add(project); |
|
f7eb47b…
|
lmata
|
314 |
if (phaseProjects.length) { |
|
f7eb47b…
|
lmata
|
315 |
let testGroupsInPhase = 0; |
|
f7eb47b…
|
lmata
|
316 |
const phase = { dispatcher: new import_dispatcher.Dispatcher(testRun.config, testRun.reporter, testRun.failureTracker), projects: [] }; |
|
f7eb47b…
|
lmata
|
317 |
testRun.phases.push(phase); |
|
f7eb47b…
|
lmata
|
318 |
for (const project of phaseProjects) { |
|
f7eb47b…
|
lmata
|
319 |
const projectSuite = projectToSuite.get(project); |
|
f7eb47b…
|
lmata
|
320 |
const testGroups = (0, import_testGroups.createTestGroups)(projectSuite, testRun.config.config.workers); |
|
f7eb47b…
|
lmata
|
321 |
phase.projects.push({ project, projectSuite, testGroups }); |
|
f7eb47b…
|
lmata
|
322 |
testGroupsInPhase += Math.min(project.workers ?? Number.MAX_SAFE_INTEGER, testGroups.length); |
|
f7eb47b…
|
lmata
|
323 |
} |
|
f7eb47b…
|
lmata
|
324 |
(0, import_utilsBundle.debug)("pw:test:task")(`created phase #${testRun.phases.length} with ${phase.projects.map((p) => p.project.project.name).sort()} projects, ${testGroupsInPhase} testGroups`); |
|
f7eb47b…
|
lmata
|
325 |
maxConcurrentTestGroups = Math.max(maxConcurrentTestGroups, testGroupsInPhase); |
|
f7eb47b…
|
lmata
|
326 |
} |
|
f7eb47b…
|
lmata
|
327 |
} |
|
f7eb47b…
|
lmata
|
328 |
testRun.config.config.metadata.actualWorkers = Math.min(testRun.config.config.workers, maxConcurrentTestGroups); |
|
f7eb47b…
|
lmata
|
329 |
} |
|
f7eb47b…
|
lmata
|
330 |
}; |
|
f7eb47b…
|
lmata
|
331 |
} |
|
f7eb47b…
|
lmata
|
332 |
function createRunTestsTask() { |
|
f7eb47b…
|
lmata
|
333 |
return { |
|
f7eb47b…
|
lmata
|
334 |
title: "test suite", |
|
f7eb47b…
|
lmata
|
335 |
setup: async ({ phases, failureTracker }) => { |
|
f7eb47b…
|
lmata
|
336 |
const successfulProjects = /* @__PURE__ */ new Set(); |
|
f7eb47b…
|
lmata
|
337 |
const extraEnvByProjectId = /* @__PURE__ */ new Map(); |
|
f7eb47b…
|
lmata
|
338 |
const teardownToSetups = (0, import_projectUtils.buildTeardownToSetupsMap)(phases.map((phase) => phase.projects.map((p) => p.project)).flat()); |
|
f7eb47b…
|
lmata
|
339 |
for (const { dispatcher, projects } of phases) { |
|
f7eb47b…
|
lmata
|
340 |
const phaseTestGroups = []; |
|
f7eb47b…
|
lmata
|
341 |
for (const { project, testGroups } of projects) { |
|
f7eb47b…
|
lmata
|
342 |
let extraEnv = {}; |
|
f7eb47b…
|
lmata
|
343 |
for (const dep of project.deps) |
|
f7eb47b…
|
lmata
|
344 |
extraEnv = { ...extraEnv, ...extraEnvByProjectId.get(dep.id) }; |
|
f7eb47b…
|
lmata
|
345 |
for (const setup of teardownToSetups.get(project) || []) |
|
f7eb47b…
|
lmata
|
346 |
extraEnv = { ...extraEnv, ...extraEnvByProjectId.get(setup.id) }; |
|
f7eb47b…
|
lmata
|
347 |
extraEnvByProjectId.set(project.id, extraEnv); |
|
f7eb47b…
|
lmata
|
348 |
const hasFailedDeps = project.deps.some((p) => !successfulProjects.has(p)); |
|
f7eb47b…
|
lmata
|
349 |
if (!hasFailedDeps) |
|
f7eb47b…
|
lmata
|
350 |
phaseTestGroups.push(...testGroups); |
|
f7eb47b…
|
lmata
|
351 |
} |
|
f7eb47b…
|
lmata
|
352 |
if (phaseTestGroups.length) { |
|
f7eb47b…
|
lmata
|
353 |
await dispatcher.run(phaseTestGroups, extraEnvByProjectId); |
|
f7eb47b…
|
lmata
|
354 |
await dispatcher.stop(); |
|
f7eb47b…
|
lmata
|
355 |
for (const [projectId, envProduced] of dispatcher.producedEnvByProjectId()) { |
|
f7eb47b…
|
lmata
|
356 |
const extraEnv = extraEnvByProjectId.get(projectId) || {}; |
|
f7eb47b…
|
lmata
|
357 |
extraEnvByProjectId.set(projectId, { ...extraEnv, ...envProduced }); |
|
f7eb47b…
|
lmata
|
358 |
} |
|
f7eb47b…
|
lmata
|
359 |
} |
|
f7eb47b…
|
lmata
|
360 |
if (!failureTracker.hasWorkerErrors()) { |
|
f7eb47b…
|
lmata
|
361 |
for (const { project, projectSuite } of projects) { |
|
f7eb47b…
|
lmata
|
362 |
const hasFailedDeps = project.deps.some((p) => !successfulProjects.has(p)); |
|
f7eb47b…
|
lmata
|
363 |
if (!hasFailedDeps && !projectSuite.allTests().some((test) => !test.ok())) |
|
f7eb47b…
|
lmata
|
364 |
successfulProjects.add(project); |
|
f7eb47b…
|
lmata
|
365 |
} |
|
f7eb47b…
|
lmata
|
366 |
} |
|
f7eb47b…
|
lmata
|
367 |
} |
|
f7eb47b…
|
lmata
|
368 |
}, |
|
f7eb47b…
|
lmata
|
369 |
teardown: async ({ phases }) => { |
|
f7eb47b…
|
lmata
|
370 |
for (const { dispatcher } of phases.reverse()) |
|
f7eb47b…
|
lmata
|
371 |
await dispatcher.stop(); |
|
f7eb47b…
|
lmata
|
372 |
} |
|
f7eb47b…
|
lmata
|
373 |
}; |
|
f7eb47b…
|
lmata
|
374 |
} |
|
f7eb47b…
|
lmata
|
375 |
function createStartDevServerTask() { |
|
f7eb47b…
|
lmata
|
376 |
return { |
|
f7eb47b…
|
lmata
|
377 |
title: "start dev server", |
|
f7eb47b…
|
lmata
|
378 |
setup: async ({ config }, errors, softErrors) => { |
|
f7eb47b…
|
lmata
|
379 |
if (config.plugins.some((plugin) => !!plugin.devServerCleanup)) { |
|
f7eb47b…
|
lmata
|
380 |
errors.push({ message: `DevServer is already running` }); |
|
f7eb47b…
|
lmata
|
381 |
return; |
|
f7eb47b…
|
lmata
|
382 |
} |
|
f7eb47b…
|
lmata
|
383 |
for (const plugin of config.plugins) |
|
f7eb47b…
|
lmata
|
384 |
plugin.devServerCleanup = await plugin.instance?.startDevServer?.(); |
|
f7eb47b…
|
lmata
|
385 |
if (!config.plugins.some((plugin) => !!plugin.devServerCleanup)) |
|
f7eb47b…
|
lmata
|
386 |
errors.push({ message: `DevServer is not available in the package you are using. Did you mean to use component testing?` }); |
|
f7eb47b…
|
lmata
|
387 |
}, |
|
f7eb47b…
|
lmata
|
388 |
teardown: async ({ config }) => { |
|
f7eb47b…
|
lmata
|
389 |
for (const plugin of config.plugins) { |
|
f7eb47b…
|
lmata
|
390 |
await plugin.devServerCleanup?.(); |
|
f7eb47b…
|
lmata
|
391 |
plugin.devServerCleanup = void 0; |
|
f7eb47b…
|
lmata
|
392 |
} |
|
f7eb47b…
|
lmata
|
393 |
} |
|
f7eb47b…
|
lmata
|
394 |
}; |
|
f7eb47b…
|
lmata
|
395 |
} |
|
f7eb47b…
|
lmata
|
396 |
// Annotate the CommonJS export names for ESM import in node: |
|
f7eb47b…
|
lmata
|
397 |
0 && (module.exports = { |
|
f7eb47b…
|
lmata
|
398 |
TestRun, |
|
f7eb47b…
|
lmata
|
399 |
createApplyRebaselinesTask, |
|
f7eb47b…
|
lmata
|
400 |
createClearCacheTask, |
|
f7eb47b…
|
lmata
|
401 |
createGlobalSetupTasks, |
|
f7eb47b…
|
lmata
|
402 |
createListFilesTask, |
|
f7eb47b…
|
lmata
|
403 |
createLoadTask, |
|
f7eb47b…
|
lmata
|
404 |
createPluginSetupTasks, |
|
f7eb47b…
|
lmata
|
405 |
createReportBeginTask, |
|
f7eb47b…
|
lmata
|
406 |
createRunTestsTasks, |
|
f7eb47b…
|
lmata
|
407 |
createStartDevServerTask, |
|
f7eb47b…
|
lmata
|
408 |
runTasks, |
|
f7eb47b…
|
lmata
|
409 |
runTasksDeferCleanup |
|
f7eb47b…
|
lmata
|
410 |
}); |