(triggerId: string)
| 1369 | |
| 1370 | private _rerunTimer: any |
| 1371 | private async scheduleRerun(triggerId: string): Promise<void> { |
| 1372 | const currentCount = this.restartsCount |
| 1373 | clearTimeout(this._rerunTimer) |
| 1374 | await this.cancelPromise |
| 1375 | await this.runningPromise |
| 1376 | clearTimeout(this._rerunTimer) |
| 1377 | |
| 1378 | // server restarted |
| 1379 | if (this.restartsCount !== currentCount) { |
| 1380 | return |
| 1381 | } |
| 1382 | |
| 1383 | this._rerunTimer = setTimeout(async () => { |
| 1384 | if (this.watcher.changedTests.size === 0) { |
| 1385 | this.watcher.invalidates.clear() |
| 1386 | return |
| 1387 | } |
| 1388 | |
| 1389 | // server restarted |
| 1390 | if (this.restartsCount !== currentCount) { |
| 1391 | return |
| 1392 | } |
| 1393 | |
| 1394 | this.isFirstRun = false |
| 1395 | |
| 1396 | this.snapshot.clear() |
| 1397 | let files = Array.from(this.watcher.changedTests) |
| 1398 | |
| 1399 | if (this.filenamePattern) { |
| 1400 | const filteredFiles = await this.globTestSpecifications(this.filenamePattern) |
| 1401 | files = files.filter(file => filteredFiles.some(f => f.moduleId === file)) |
| 1402 | |
| 1403 | // A file that does not match the current filename pattern was changed |
| 1404 | if (files.length === 0) { |
| 1405 | return |
| 1406 | } |
| 1407 | } |
| 1408 | |
| 1409 | this.watcher.changedTests.clear() |
| 1410 | |
| 1411 | const triggerLabel = relative(this.config.root, triggerId) |
| 1412 | // get file specifications and filter them if needed |
| 1413 | const specifications = files.flatMap(file => this.getModuleSpecifications(file)).filter((specification) => { |
| 1414 | if (this._onFilterWatchedSpecification.length === 0) { |
| 1415 | return true |
| 1416 | } |
| 1417 | return this._onFilterWatchedSpecification.every(fn => fn(specification)) |
| 1418 | }) |
| 1419 | await Promise.all([ |
| 1420 | this.report('onWatcherRerun', files, triggerLabel), |
| 1421 | ...this._onUserTestsRerun.map(fn => fn(specifications)), |
| 1422 | ]) |
| 1423 | |
| 1424 | await this.runFiles(specifications, false) |
| 1425 | |
| 1426 | await this.report('onWatcherStart', this.state.getFiles(files)) |
| 1427 | }, WATCHER_DEBOUNCE) |
| 1428 | } |
no test coverage detected