|
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 loadUtils_exports = {}; |
|
f7eb47b…
|
lmata
|
30 |
__export(loadUtils_exports, { |
|
f7eb47b…
|
lmata
|
31 |
collectProjectsAndTestFiles: () => collectProjectsAndTestFiles, |
|
f7eb47b…
|
lmata
|
32 |
createRootSuite: () => createRootSuite, |
|
f7eb47b…
|
lmata
|
33 |
loadFileSuites: () => loadFileSuites, |
|
f7eb47b…
|
lmata
|
34 |
loadGlobalHook: () => loadGlobalHook, |
|
f7eb47b…
|
lmata
|
35 |
loadReporter: () => loadReporter, |
|
f7eb47b…
|
lmata
|
36 |
loadTestList: () => loadTestList |
|
f7eb47b…
|
lmata
|
37 |
}); |
|
f7eb47b…
|
lmata
|
38 |
module.exports = __toCommonJS(loadUtils_exports); |
|
f7eb47b…
|
lmata
|
39 |
var import_path = __toESM(require("path")); |
|
f7eb47b…
|
lmata
|
40 |
var import_fs = __toESM(require("fs")); |
|
f7eb47b…
|
lmata
|
41 |
var import_utils = require("playwright-core/lib/utils"); |
|
f7eb47b…
|
lmata
|
42 |
var import_loaderHost = require("./loaderHost"); |
|
f7eb47b…
|
lmata
|
43 |
var import_util = require("../util"); |
|
f7eb47b…
|
lmata
|
44 |
var import_projectUtils = require("./projectUtils"); |
|
f7eb47b…
|
lmata
|
45 |
var import_testGroups = require("./testGroups"); |
|
f7eb47b…
|
lmata
|
46 |
var import_suiteUtils = require("../common/suiteUtils"); |
|
f7eb47b…
|
lmata
|
47 |
var import_test = require("../common/test"); |
|
f7eb47b…
|
lmata
|
48 |
var import_compilationCache = require("../transform/compilationCache"); |
|
f7eb47b…
|
lmata
|
49 |
var import_transform = require("../transform/transform"); |
|
f7eb47b…
|
lmata
|
50 |
var import_utilsBundle = require("../utilsBundle"); |
|
f7eb47b…
|
lmata
|
51 |
async function collectProjectsAndTestFiles(testRun, doNotRunTestsOutsideProjectFilter) { |
|
f7eb47b…
|
lmata
|
52 |
const config = testRun.config; |
|
f7eb47b…
|
lmata
|
53 |
const fsCache = /* @__PURE__ */ new Map(); |
|
f7eb47b…
|
lmata
|
54 |
const sourceMapCache = /* @__PURE__ */ new Map(); |
|
f7eb47b…
|
lmata
|
55 |
const cliFileMatcher = config.cliArgs.length ? (0, import_util.createFileMatcherFromArguments)(config.cliArgs) : null; |
|
f7eb47b…
|
lmata
|
56 |
const allFilesForProject = /* @__PURE__ */ new Map(); |
|
f7eb47b…
|
lmata
|
57 |
const filteredProjects = (0, import_projectUtils.filterProjects)(config.projects, config.cliProjectFilter); |
|
f7eb47b…
|
lmata
|
58 |
for (const project of filteredProjects) { |
|
f7eb47b…
|
lmata
|
59 |
const files = await (0, import_projectUtils.collectFilesForProject)(project, fsCache); |
|
f7eb47b…
|
lmata
|
60 |
allFilesForProject.set(project, files); |
|
f7eb47b…
|
lmata
|
61 |
} |
|
f7eb47b…
|
lmata
|
62 |
const filesToRunByProject = /* @__PURE__ */ new Map(); |
|
f7eb47b…
|
lmata
|
63 |
for (const [project, files] of allFilesForProject) { |
|
f7eb47b…
|
lmata
|
64 |
const matchedFiles = files.filter((file) => { |
|
f7eb47b…
|
lmata
|
65 |
const hasMatchingSources = sourceMapSources(file, sourceMapCache).some((source) => { |
|
f7eb47b…
|
lmata
|
66 |
if (cliFileMatcher && !cliFileMatcher(source)) |
|
f7eb47b…
|
lmata
|
67 |
return false; |
|
f7eb47b…
|
lmata
|
68 |
return true; |
|
f7eb47b…
|
lmata
|
69 |
}); |
|
f7eb47b…
|
lmata
|
70 |
return hasMatchingSources; |
|
f7eb47b…
|
lmata
|
71 |
}); |
|
f7eb47b…
|
lmata
|
72 |
const filteredFiles = matchedFiles.filter(Boolean); |
|
f7eb47b…
|
lmata
|
73 |
filesToRunByProject.set(project, filteredFiles); |
|
f7eb47b…
|
lmata
|
74 |
} |
|
f7eb47b…
|
lmata
|
75 |
const projectClosure = (0, import_projectUtils.buildProjectsClosure)([...filesToRunByProject.keys()]); |
|
f7eb47b…
|
lmata
|
76 |
for (const [project, type] of projectClosure) { |
|
f7eb47b…
|
lmata
|
77 |
if (type === "dependency") { |
|
f7eb47b…
|
lmata
|
78 |
const treatProjectAsEmpty = doNotRunTestsOutsideProjectFilter && !filteredProjects.includes(project); |
|
f7eb47b…
|
lmata
|
79 |
const files = treatProjectAsEmpty ? [] : allFilesForProject.get(project) || await (0, import_projectUtils.collectFilesForProject)(project, fsCache); |
|
f7eb47b…
|
lmata
|
80 |
filesToRunByProject.set(project, files); |
|
f7eb47b…
|
lmata
|
81 |
} |
|
f7eb47b…
|
lmata
|
82 |
} |
|
f7eb47b…
|
lmata
|
83 |
testRun.projectFiles = filesToRunByProject; |
|
f7eb47b…
|
lmata
|
84 |
testRun.projectSuites = /* @__PURE__ */ new Map(); |
|
f7eb47b…
|
lmata
|
85 |
} |
|
f7eb47b…
|
lmata
|
86 |
async function loadFileSuites(testRun, mode, errors) { |
|
f7eb47b…
|
lmata
|
87 |
const config = testRun.config; |
|
f7eb47b…
|
lmata
|
88 |
const allTestFiles = /* @__PURE__ */ new Set(); |
|
f7eb47b…
|
lmata
|
89 |
for (const files of testRun.projectFiles.values()) |
|
f7eb47b…
|
lmata
|
90 |
files.forEach((file) => allTestFiles.add(file)); |
|
f7eb47b…
|
lmata
|
91 |
const fileSuiteByFile = /* @__PURE__ */ new Map(); |
|
f7eb47b…
|
lmata
|
92 |
const loaderHost = mode === "out-of-process" ? new import_loaderHost.OutOfProcessLoaderHost(config) : new import_loaderHost.InProcessLoaderHost(config); |
|
f7eb47b…
|
lmata
|
93 |
if (await loaderHost.start(errors)) { |
|
f7eb47b…
|
lmata
|
94 |
for (const file of allTestFiles) { |
|
f7eb47b…
|
lmata
|
95 |
const fileSuite = await loaderHost.loadTestFile(file, errors); |
|
f7eb47b…
|
lmata
|
96 |
fileSuiteByFile.set(file, fileSuite); |
|
f7eb47b…
|
lmata
|
97 |
errors.push(...createDuplicateTitlesErrors(config, fileSuite)); |
|
f7eb47b…
|
lmata
|
98 |
} |
|
f7eb47b…
|
lmata
|
99 |
await loaderHost.stop(); |
|
f7eb47b…
|
lmata
|
100 |
} |
|
f7eb47b…
|
lmata
|
101 |
for (const file of allTestFiles) { |
|
f7eb47b…
|
lmata
|
102 |
for (const dependency of (0, import_compilationCache.dependenciesForTestFile)(file)) { |
|
f7eb47b…
|
lmata
|
103 |
if (allTestFiles.has(dependency)) { |
|
f7eb47b…
|
lmata
|
104 |
const importer = import_path.default.relative(config.config.rootDir, file); |
|
f7eb47b…
|
lmata
|
105 |
const importee = import_path.default.relative(config.config.rootDir, dependency); |
|
f7eb47b…
|
lmata
|
106 |
errors.push({ |
|
f7eb47b…
|
lmata
|
107 |
message: `Error: test file "${importer}" should not import test file "${importee}"`, |
|
f7eb47b…
|
lmata
|
108 |
location: { file, line: 1, column: 1 } |
|
f7eb47b…
|
lmata
|
109 |
}); |
|
f7eb47b…
|
lmata
|
110 |
} |
|
f7eb47b…
|
lmata
|
111 |
} |
|
f7eb47b…
|
lmata
|
112 |
} |
|
f7eb47b…
|
lmata
|
113 |
for (const [project, files] of testRun.projectFiles) { |
|
f7eb47b…
|
lmata
|
114 |
const suites = files.map((file) => fileSuiteByFile.get(file)).filter(Boolean); |
|
f7eb47b…
|
lmata
|
115 |
testRun.projectSuites.set(project, suites); |
|
f7eb47b…
|
lmata
|
116 |
} |
|
f7eb47b…
|
lmata
|
117 |
} |
|
f7eb47b…
|
lmata
|
118 |
async function createRootSuite(testRun, errors, shouldFilterOnly) { |
|
f7eb47b…
|
lmata
|
119 |
const config = testRun.config; |
|
f7eb47b…
|
lmata
|
120 |
const rootSuite = new import_test.Suite("", "root"); |
|
f7eb47b…
|
lmata
|
121 |
const projectSuites = /* @__PURE__ */ new Map(); |
|
f7eb47b…
|
lmata
|
122 |
const filteredProjectSuites = /* @__PURE__ */ new Map(); |
|
f7eb47b…
|
lmata
|
123 |
{ |
|
f7eb47b…
|
lmata
|
124 |
const cliFileFilters = (0, import_util.createFileFiltersFromArguments)(config.cliArgs); |
|
f7eb47b…
|
lmata
|
125 |
const grepMatcher = config.cliGrep ? (0, import_util.createTitleMatcher)((0, import_util.forceRegExp)(config.cliGrep)) : () => true; |
|
f7eb47b…
|
lmata
|
126 |
const grepInvertMatcher = config.cliGrepInvert ? (0, import_util.createTitleMatcher)((0, import_util.forceRegExp)(config.cliGrepInvert)) : () => false; |
|
f7eb47b…
|
lmata
|
127 |
const cliTitleMatcher = (title) => !grepInvertMatcher(title) && grepMatcher(title); |
|
f7eb47b…
|
lmata
|
128 |
for (const [project, fileSuites] of testRun.projectSuites) { |
|
f7eb47b…
|
lmata
|
129 |
const projectSuite = createProjectSuite(project, fileSuites); |
|
f7eb47b…
|
lmata
|
130 |
projectSuites.set(project, projectSuite); |
|
f7eb47b…
|
lmata
|
131 |
const filteredProjectSuite = filterProjectSuite(projectSuite, { cliFileFilters, cliTitleMatcher, testFilters: config.preOnlyTestFilters }); |
|
f7eb47b…
|
lmata
|
132 |
filteredProjectSuites.set(project, filteredProjectSuite); |
|
f7eb47b…
|
lmata
|
133 |
} |
|
f7eb47b…
|
lmata
|
134 |
} |
|
f7eb47b…
|
lmata
|
135 |
if (shouldFilterOnly) { |
|
f7eb47b…
|
lmata
|
136 |
const filteredRoot = new import_test.Suite("", "root"); |
|
f7eb47b…
|
lmata
|
137 |
for (const filteredProjectSuite of filteredProjectSuites.values()) |
|
f7eb47b…
|
lmata
|
138 |
filteredRoot._addSuite(filteredProjectSuite); |
|
f7eb47b…
|
lmata
|
139 |
(0, import_suiteUtils.filterOnly)(filteredRoot); |
|
f7eb47b…
|
lmata
|
140 |
for (const [project, filteredProjectSuite] of filteredProjectSuites) { |
|
f7eb47b…
|
lmata
|
141 |
if (!filteredRoot.suites.includes(filteredProjectSuite)) |
|
f7eb47b…
|
lmata
|
142 |
filteredProjectSuites.delete(project); |
|
f7eb47b…
|
lmata
|
143 |
} |
|
f7eb47b…
|
lmata
|
144 |
} |
|
f7eb47b…
|
lmata
|
145 |
const projectClosure = (0, import_projectUtils.buildProjectsClosure)([...filteredProjectSuites.keys()], (project) => filteredProjectSuites.get(project)._hasTests()); |
|
f7eb47b…
|
lmata
|
146 |
for (const [project, type] of projectClosure) { |
|
f7eb47b…
|
lmata
|
147 |
if (type === "top-level") { |
|
f7eb47b…
|
lmata
|
148 |
project.project.repeatEach = project.fullConfig.configCLIOverrides.repeatEach ?? project.project.repeatEach; |
|
f7eb47b…
|
lmata
|
149 |
rootSuite._addSuite(buildProjectSuite(project, filteredProjectSuites.get(project))); |
|
f7eb47b…
|
lmata
|
150 |
} |
|
f7eb47b…
|
lmata
|
151 |
} |
|
f7eb47b…
|
lmata
|
152 |
if (config.config.forbidOnly) { |
|
f7eb47b…
|
lmata
|
153 |
const onlyTestsAndSuites = rootSuite._getOnlyItems(); |
|
f7eb47b…
|
lmata
|
154 |
if (onlyTestsAndSuites.length > 0) { |
|
f7eb47b…
|
lmata
|
155 |
const configFilePath = config.config.configFile ? import_path.default.relative(config.config.rootDir, config.config.configFile) : void 0; |
|
f7eb47b…
|
lmata
|
156 |
errors.push(...createForbidOnlyErrors(onlyTestsAndSuites, config.configCLIOverrides.forbidOnly, configFilePath)); |
|
f7eb47b…
|
lmata
|
157 |
} |
|
f7eb47b…
|
lmata
|
158 |
} |
|
f7eb47b…
|
lmata
|
159 |
if (config.config.shard) { |
|
f7eb47b…
|
lmata
|
160 |
const testGroups = []; |
|
f7eb47b…
|
lmata
|
161 |
for (const projectSuite of rootSuite.suites) { |
|
f7eb47b…
|
lmata
|
162 |
for (const group of (0, import_testGroups.createTestGroups)(projectSuite, config.config.shard.total)) |
|
f7eb47b…
|
lmata
|
163 |
testGroups.push(group); |
|
f7eb47b…
|
lmata
|
164 |
} |
|
f7eb47b…
|
lmata
|
165 |
const testGroupsInThisShard = (0, import_testGroups.filterForShard)(config.config.shard, config.configCLIOverrides.shardWeights, testGroups); |
|
f7eb47b…
|
lmata
|
166 |
const testsInThisShard = /* @__PURE__ */ new Set(); |
|
f7eb47b…
|
lmata
|
167 |
for (const group of testGroupsInThisShard) { |
|
f7eb47b…
|
lmata
|
168 |
for (const test of group.tests) |
|
f7eb47b…
|
lmata
|
169 |
testsInThisShard.add(test); |
|
f7eb47b…
|
lmata
|
170 |
} |
|
f7eb47b…
|
lmata
|
171 |
(0, import_suiteUtils.filterTestsRemoveEmptySuites)(rootSuite, (test) => testsInThisShard.has(test)); |
|
f7eb47b…
|
lmata
|
172 |
} |
|
f7eb47b…
|
lmata
|
173 |
if (config.postShardTestFilters.length) |
|
f7eb47b…
|
lmata
|
174 |
(0, import_suiteUtils.filterTestsRemoveEmptySuites)(rootSuite, (test) => config.postShardTestFilters.every((filter) => filter(test))); |
|
f7eb47b…
|
lmata
|
175 |
const topLevelProjects = []; |
|
f7eb47b…
|
lmata
|
176 |
{ |
|
f7eb47b…
|
lmata
|
177 |
const projectClosure2 = new Map((0, import_projectUtils.buildProjectsClosure)(rootSuite.suites.map((suite) => suite._fullProject))); |
|
f7eb47b…
|
lmata
|
178 |
for (const [project, level] of projectClosure2.entries()) { |
|
f7eb47b…
|
lmata
|
179 |
if (level === "dependency") |
|
f7eb47b…
|
lmata
|
180 |
rootSuite._prependSuite(buildProjectSuite(project, projectSuites.get(project))); |
|
f7eb47b…
|
lmata
|
181 |
else |
|
f7eb47b…
|
lmata
|
182 |
topLevelProjects.push(project); |
|
f7eb47b…
|
lmata
|
183 |
} |
|
f7eb47b…
|
lmata
|
184 |
} |
|
f7eb47b…
|
lmata
|
185 |
return { rootSuite, topLevelProjects }; |
|
f7eb47b…
|
lmata
|
186 |
} |
|
f7eb47b…
|
lmata
|
187 |
function createProjectSuite(project, fileSuites) { |
|
f7eb47b…
|
lmata
|
188 |
const projectSuite = new import_test.Suite(project.project.name, "project"); |
|
f7eb47b…
|
lmata
|
189 |
for (const fileSuite of fileSuites) |
|
f7eb47b…
|
lmata
|
190 |
projectSuite._addSuite((0, import_suiteUtils.bindFileSuiteToProject)(project, fileSuite)); |
|
f7eb47b…
|
lmata
|
191 |
const grepMatcher = (0, import_util.createTitleMatcher)(project.project.grep); |
|
f7eb47b…
|
lmata
|
192 |
const grepInvertMatcher = project.project.grepInvert ? (0, import_util.createTitleMatcher)(project.project.grepInvert) : null; |
|
f7eb47b…
|
lmata
|
193 |
(0, import_suiteUtils.filterTestsRemoveEmptySuites)(projectSuite, (test) => { |
|
f7eb47b…
|
lmata
|
194 |
const grepTitle = test._grepTitleWithTags(); |
|
f7eb47b…
|
lmata
|
195 |
if (grepInvertMatcher?.(grepTitle)) |
|
f7eb47b…
|
lmata
|
196 |
return false; |
|
f7eb47b…
|
lmata
|
197 |
return grepMatcher(grepTitle); |
|
f7eb47b…
|
lmata
|
198 |
}); |
|
f7eb47b…
|
lmata
|
199 |
return projectSuite; |
|
f7eb47b…
|
lmata
|
200 |
} |
|
f7eb47b…
|
lmata
|
201 |
function filterProjectSuite(projectSuite, options) { |
|
f7eb47b…
|
lmata
|
202 |
if (!options.cliFileFilters.length && !options.cliTitleMatcher && !options.testFilters.length) |
|
f7eb47b…
|
lmata
|
203 |
return projectSuite; |
|
f7eb47b…
|
lmata
|
204 |
const result = projectSuite._deepClone(); |
|
f7eb47b…
|
lmata
|
205 |
if (options.cliFileFilters.length) |
|
f7eb47b…
|
lmata
|
206 |
(0, import_suiteUtils.filterByFocusedLine)(result, options.cliFileFilters); |
|
f7eb47b…
|
lmata
|
207 |
(0, import_suiteUtils.filterTestsRemoveEmptySuites)(result, (test) => { |
|
f7eb47b…
|
lmata
|
208 |
if (!options.testFilters.every((filter) => filter(test))) |
|
f7eb47b…
|
lmata
|
209 |
return false; |
|
f7eb47b…
|
lmata
|
210 |
if (options.cliTitleMatcher && !options.cliTitleMatcher(test._grepTitleWithTags())) |
|
f7eb47b…
|
lmata
|
211 |
return false; |
|
f7eb47b…
|
lmata
|
212 |
return true; |
|
f7eb47b…
|
lmata
|
213 |
}); |
|
f7eb47b…
|
lmata
|
214 |
return result; |
|
f7eb47b…
|
lmata
|
215 |
} |
|
f7eb47b…
|
lmata
|
216 |
function buildProjectSuite(project, projectSuite) { |
|
f7eb47b…
|
lmata
|
217 |
const result = new import_test.Suite(project.project.name, "project"); |
|
f7eb47b…
|
lmata
|
218 |
result._fullProject = project; |
|
f7eb47b…
|
lmata
|
219 |
if (project.fullyParallel) |
|
f7eb47b…
|
lmata
|
220 |
result._parallelMode = "parallel"; |
|
f7eb47b…
|
lmata
|
221 |
for (const fileSuite of projectSuite.suites) { |
|
f7eb47b…
|
lmata
|
222 |
result._addSuite(fileSuite); |
|
f7eb47b…
|
lmata
|
223 |
for (let repeatEachIndex = 1; repeatEachIndex < project.project.repeatEach; repeatEachIndex++) { |
|
f7eb47b…
|
lmata
|
224 |
const clone = fileSuite._deepClone(); |
|
f7eb47b…
|
lmata
|
225 |
(0, import_suiteUtils.applyRepeatEachIndex)(project, clone, repeatEachIndex); |
|
f7eb47b…
|
lmata
|
226 |
result._addSuite(clone); |
|
f7eb47b…
|
lmata
|
227 |
} |
|
f7eb47b…
|
lmata
|
228 |
} |
|
f7eb47b…
|
lmata
|
229 |
return result; |
|
f7eb47b…
|
lmata
|
230 |
} |
|
f7eb47b…
|
lmata
|
231 |
function createForbidOnlyErrors(onlyTestsAndSuites, forbidOnlyCLIFlag, configFilePath) { |
|
f7eb47b…
|
lmata
|
232 |
const errors = []; |
|
f7eb47b…
|
lmata
|
233 |
for (const testOrSuite of onlyTestsAndSuites) { |
|
f7eb47b…
|
lmata
|
234 |
const title = testOrSuite.titlePath().slice(2).join(" "); |
|
f7eb47b…
|
lmata
|
235 |
const configFilePathName = configFilePath ? `'${configFilePath}'` : "the Playwright configuration file"; |
|
f7eb47b…
|
lmata
|
236 |
const forbidOnlySource = forbidOnlyCLIFlag ? `'--forbid-only' CLI flag` : `'forbidOnly' option in ${configFilePathName}`; |
|
f7eb47b…
|
lmata
|
237 |
const error = { |
|
f7eb47b…
|
lmata
|
238 |
message: `Error: item focused with '.only' is not allowed due to the ${forbidOnlySource}: "${title}"`, |
|
f7eb47b…
|
lmata
|
239 |
location: testOrSuite.location |
|
f7eb47b…
|
lmata
|
240 |
}; |
|
f7eb47b…
|
lmata
|
241 |
errors.push(error); |
|
f7eb47b…
|
lmata
|
242 |
} |
|
f7eb47b…
|
lmata
|
243 |
return errors; |
|
f7eb47b…
|
lmata
|
244 |
} |
|
f7eb47b…
|
lmata
|
245 |
function createDuplicateTitlesErrors(config, fileSuite) { |
|
f7eb47b…
|
lmata
|
246 |
const errors = []; |
|
f7eb47b…
|
lmata
|
247 |
const testsByFullTitle = /* @__PURE__ */ new Map(); |
|
f7eb47b…
|
lmata
|
248 |
for (const test of fileSuite.allTests()) { |
|
f7eb47b…
|
lmata
|
249 |
const fullTitle = test.titlePath().slice(1).join(" \u203A "); |
|
f7eb47b…
|
lmata
|
250 |
const existingTest = testsByFullTitle.get(fullTitle); |
|
f7eb47b…
|
lmata
|
251 |
if (existingTest) { |
|
f7eb47b…
|
lmata
|
252 |
const error = { |
|
f7eb47b…
|
lmata
|
253 |
message: `Error: duplicate test title "${fullTitle}", first declared in ${buildItemLocation(config.config.rootDir, existingTest)}`, |
|
f7eb47b…
|
lmata
|
254 |
location: test.location |
|
f7eb47b…
|
lmata
|
255 |
}; |
|
f7eb47b…
|
lmata
|
256 |
errors.push(error); |
|
f7eb47b…
|
lmata
|
257 |
} |
|
f7eb47b…
|
lmata
|
258 |
testsByFullTitle.set(fullTitle, test); |
|
f7eb47b…
|
lmata
|
259 |
} |
|
f7eb47b…
|
lmata
|
260 |
return errors; |
|
f7eb47b…
|
lmata
|
261 |
} |
|
f7eb47b…
|
lmata
|
262 |
function buildItemLocation(rootDir, testOrSuite) { |
|
f7eb47b…
|
lmata
|
263 |
if (!testOrSuite.location) |
|
f7eb47b…
|
lmata
|
264 |
return ""; |
|
f7eb47b…
|
lmata
|
265 |
return `${import_path.default.relative(rootDir, testOrSuite.location.file)}:${testOrSuite.location.line}`; |
|
f7eb47b…
|
lmata
|
266 |
} |
|
f7eb47b…
|
lmata
|
267 |
async function requireOrImportDefaultFunction(file, expectConstructor) { |
|
f7eb47b…
|
lmata
|
268 |
let func = await (0, import_transform.requireOrImport)(file); |
|
f7eb47b…
|
lmata
|
269 |
if (func && typeof func === "object" && "default" in func) |
|
f7eb47b…
|
lmata
|
270 |
func = func["default"]; |
|
f7eb47b…
|
lmata
|
271 |
if (typeof func !== "function") |
|
f7eb47b…
|
lmata
|
272 |
throw (0, import_util.errorWithFile)(file, `file must export a single ${expectConstructor ? "class" : "function"}.`); |
|
f7eb47b…
|
lmata
|
273 |
return func; |
|
f7eb47b…
|
lmata
|
274 |
} |
|
f7eb47b…
|
lmata
|
275 |
function loadGlobalHook(config, file) { |
|
f7eb47b…
|
lmata
|
276 |
return requireOrImportDefaultFunction(import_path.default.resolve(config.config.rootDir, file), false); |
|
f7eb47b…
|
lmata
|
277 |
} |
|
f7eb47b…
|
lmata
|
278 |
function loadReporter(config, file) { |
|
f7eb47b…
|
lmata
|
279 |
return requireOrImportDefaultFunction(config ? import_path.default.resolve(config.config.rootDir, file) : file, true); |
|
f7eb47b…
|
lmata
|
280 |
} |
|
f7eb47b…
|
lmata
|
281 |
function sourceMapSources(file, cache) { |
|
f7eb47b…
|
lmata
|
282 |
let sources = [file]; |
|
f7eb47b…
|
lmata
|
283 |
if (!file.endsWith(".js")) |
|
f7eb47b…
|
lmata
|
284 |
return sources; |
|
f7eb47b…
|
lmata
|
285 |
if (cache.has(file)) |
|
f7eb47b…
|
lmata
|
286 |
return cache.get(file); |
|
f7eb47b…
|
lmata
|
287 |
try { |
|
f7eb47b…
|
lmata
|
288 |
const sourceMap = import_utilsBundle.sourceMapSupport.retrieveSourceMap(file); |
|
f7eb47b…
|
lmata
|
289 |
const sourceMapData = typeof sourceMap?.map === "string" ? JSON.parse(sourceMap.map) : sourceMap?.map; |
|
f7eb47b…
|
lmata
|
290 |
if (sourceMapData?.sources) |
|
f7eb47b…
|
lmata
|
291 |
sources = sourceMapData.sources.map((source) => import_path.default.resolve(import_path.default.dirname(file), source)); |
|
f7eb47b…
|
lmata
|
292 |
} finally { |
|
f7eb47b…
|
lmata
|
293 |
cache.set(file, sources); |
|
f7eb47b…
|
lmata
|
294 |
return sources; |
|
f7eb47b…
|
lmata
|
295 |
} |
|
f7eb47b…
|
lmata
|
296 |
} |
|
f7eb47b…
|
lmata
|
297 |
async function loadTestList(config, filePath) { |
|
f7eb47b…
|
lmata
|
298 |
try { |
|
f7eb47b…
|
lmata
|
299 |
const content = await import_fs.default.promises.readFile(filePath, "utf-8"); |
|
f7eb47b…
|
lmata
|
300 |
const lines = content.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#")); |
|
f7eb47b…
|
lmata
|
301 |
const descriptions = lines.map((line) => { |
|
f7eb47b…
|
lmata
|
302 |
const delimiter = line.includes("\u203A") ? "\u203A" : ">"; |
|
f7eb47b…
|
lmata
|
303 |
const tokens = line.split(delimiter).map((token) => token.trim()); |
|
f7eb47b…
|
lmata
|
304 |
let project; |
|
f7eb47b…
|
lmata
|
305 |
if (tokens[0].startsWith("[")) { |
|
f7eb47b…
|
lmata
|
306 |
if (!tokens[0].endsWith("]")) |
|
f7eb47b…
|
lmata
|
307 |
throw new Error(`Malformed test description: ${line}`); |
|
f7eb47b…
|
lmata
|
308 |
project = tokens[0].substring(1, tokens[0].length - 1); |
|
f7eb47b…
|
lmata
|
309 |
tokens.shift(); |
|
f7eb47b…
|
lmata
|
310 |
} |
|
f7eb47b…
|
lmata
|
311 |
return { project, file: (0, import_utils.toPosixPath)((0, import_util.parseLocationArg)(tokens[0]).file), titlePath: tokens.slice(1) }; |
|
f7eb47b…
|
lmata
|
312 |
}); |
|
f7eb47b…
|
lmata
|
313 |
return (test) => descriptions.some((d) => { |
|
f7eb47b…
|
lmata
|
314 |
const [projectName, , ...titles] = test.titlePath(); |
|
f7eb47b…
|
lmata
|
315 |
if (d.project !== void 0 && d.project !== projectName) |
|
f7eb47b…
|
lmata
|
316 |
return false; |
|
f7eb47b…
|
lmata
|
317 |
const relativeFile = (0, import_utils.toPosixPath)(import_path.default.relative(config.config.rootDir, test.location.file)); |
|
f7eb47b…
|
lmata
|
318 |
if (relativeFile !== d.file) |
|
f7eb47b…
|
lmata
|
319 |
return false; |
|
f7eb47b…
|
lmata
|
320 |
return d.titlePath.length <= titles.length && d.titlePath.every((_, index) => titles[index] === d.titlePath[index]); |
|
f7eb47b…
|
lmata
|
321 |
}); |
|
f7eb47b…
|
lmata
|
322 |
} catch (e) { |
|
f7eb47b…
|
lmata
|
323 |
throw (0, import_util.errorWithFile)(filePath, "Cannot read test list file: " + e.message); |
|
f7eb47b…
|
lmata
|
324 |
} |
|
f7eb47b…
|
lmata
|
325 |
} |
|
f7eb47b…
|
lmata
|
326 |
// Annotate the CommonJS export names for ESM import in node: |
|
f7eb47b…
|
lmata
|
327 |
0 && (module.exports = { |
|
f7eb47b…
|
lmata
|
328 |
collectProjectsAndTestFiles, |
|
f7eb47b…
|
lmata
|
329 |
createRootSuite, |
|
f7eb47b…
|
lmata
|
330 |
loadFileSuites, |
|
f7eb47b…
|
lmata
|
331 |
loadGlobalHook, |
|
f7eb47b…
|
lmata
|
332 |
loadReporter, |
|
f7eb47b…
|
lmata
|
333 |
loadTestList |
|
f7eb47b…
|
lmata
|
334 |
}); |