(
name: string,
factory: SuiteFactory = () => {},
mode: RunMode,
each?: boolean,
suiteOptions?: SuiteOptions,
)
| 302 | |
| 303 | // implementations |
| 304 | function createSuiteCollector( |
| 305 | name: string, |
| 306 | factory: SuiteFactory = () => {}, |
| 307 | mode: RunMode, |
| 308 | each?: boolean, |
| 309 | suiteOptions?: SuiteOptions, |
| 310 | ) { |
| 311 | const tasks: (Test | Suite | SuiteCollector)[] = [] |
| 312 | |
| 313 | let suite!: Suite |
| 314 | initSuite(true) |
| 315 | |
| 316 | const task = function (name = '', options: TaskCustomOptions = {}) { |
| 317 | const currentSuite = collectorContext.currentSuite?.suite |
| 318 | const parentTask = currentSuite ?? collectorContext.currentSuite?.file |
| 319 | const parentTags = parentTask?.tags || [] |
| 320 | const testTags = unique([...parentTags, ...toArray(options.tags)]) |
| 321 | const tagsOptions = testTags |
| 322 | .map((tag) => { |
| 323 | const tagDefinition = runner.config.tags?.find(t => t.name === tag) |
| 324 | if (!tagDefinition && runner.config.strictTags) { |
| 325 | throw createNoTagsError(runner.config.tags, tag) |
| 326 | } |
| 327 | return tagDefinition |
| 328 | }) |
| 329 | .filter(r => r != null) |
| 330 | // higher priority should be last, run 1, 2, 3, ... etc |
| 331 | .sort((tag1, tag2) => (tag2.priority ?? POSITIVE_INFINITY) - (tag1.priority ?? POSITIVE_INFINITY)) |
| 332 | .reduce((acc, tag) => { |
| 333 | const { name, description, priority, meta, ...options } = tag |
| 334 | Object.assign(acc, options) |
| 335 | if (meta) { |
| 336 | acc.meta = Object.assign(acc.meta ?? Object.create(null), meta) |
| 337 | } |
| 338 | return acc |
| 339 | }, {} as TestOptions) |
| 340 | |
| 341 | const testOwnMeta = options.meta |
| 342 | options = { |
| 343 | ...tagsOptions, |
| 344 | ...options, |
| 345 | } |
| 346 | const timeout = options.timeout ?? runner.config.testTimeout |
| 347 | const parentMeta = currentSuite?.meta |
| 348 | const tagMeta = tagsOptions.meta |
| 349 | const testMeta = Object.create(null) |
| 350 | if (tagMeta) { |
| 351 | Object.assign(testMeta, tagMeta) |
| 352 | } |
| 353 | if (parentMeta) { |
| 354 | Object.assign(testMeta, parentMeta) |
| 355 | } |
| 356 | if (testOwnMeta) { |
| 357 | Object.assign(testMeta, testOwnMeta) |
| 358 | } |
| 359 | const task: Test = { |
| 360 | id: '', |
| 361 | name, |
no test coverage detected