(testSelector?: string)
| 456 | |
| 457 | let testsSelector: string; |
| 458 | export function runAll(testSelector?: string) { |
| 459 | testsSelector = testSelector; |
| 460 | if (running) { |
| 461 | // TODO: We may schedule pending run requests |
| 462 | return; |
| 463 | } |
| 464 | |
| 465 | let singleModuleName, singleTestName; |
| 466 | if (testSelector) { |
| 467 | const pair = testSelector.split('.'); |
| 468 | singleModuleName = pair[0]; |
| 469 | if (singleModuleName) { |
| 470 | if (singleModuleName.length === 0) { |
| 471 | singleModuleName = undefined; |
| 472 | } else { |
| 473 | singleModuleName = singleModuleName.toLowerCase(); |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | singleTestName = pair[1]; |
| 478 | if (singleTestName) { |
| 479 | if (singleTestName.length === 0) { |
| 480 | singleTestName = undefined; |
| 481 | } else { |
| 482 | singleTestName = singleTestName.toLowerCase(); |
| 483 | } |
| 484 | } |
| 485 | } |
| 486 | |
| 487 | console.log('TESTS: ' + singleModuleName ? singleModuleName : '' + ' ' + singleTestName ? singleTestName : ''); |
| 488 | |
| 489 | testsQueue.push( |
| 490 | new TestInfo(() => { |
| 491 | running = true; |
| 492 | startTime = TKUnit.time(); |
| 493 | }), |
| 494 | ); |
| 495 | for (const name in allTests) { |
| 496 | if (singleModuleName && singleModuleName !== name.toLowerCase()) { |
| 497 | continue; |
| 498 | } |
| 499 | |
| 500 | const testModule = allTests[name]; |
| 501 | |
| 502 | // In ESM environments (like Vite), module namespace objects are not extensible. |
| 503 | // Some tests expect to set arbitrary properties like `name` on the test instance. |
| 504 | // If a module doesn't provide `createTestCase()`, wrap its exports in a plain |
| 505 | // mutable object to safely attach metadata without mutating the namespace object. |
| 506 | const test = testModule.createTestCase ? testModule.createTestCase() : ({ ...testModule } as any); |
| 507 | test.name = name; |
| 508 | |
| 509 | testsQueue.push(new TestInfo(startLog, test)); |
| 510 | |
| 511 | if (test.setUpModule) { |
| 512 | testsQueue.push(new TestInfo(test.setUpModule, test)); |
| 513 | } |
| 514 | |
| 515 | for (const testName of getAllProperties(test)) { |
no test coverage detected