({ owners, eventType })
| 628 | |
| 629 | // Watch for changes in current filtered files |
| 630 | const onChanged = ({ owners, eventType }) => { |
| 631 | if (!opts.hasFiles && (eventType === 'rename' || eventType === 'change')) { |
| 632 | const updatedTestFiles = createTestFileList(opts.globPatterns, opts.cwd); |
| 633 | const newFileName = ArrayPrototypeFind(updatedTestFiles, (x) => !ArrayPrototypeIncludes(testFiles, x)); |
| 634 | const previousFileName = ArrayPrototypeFind(testFiles, (x) => !ArrayPrototypeIncludes(updatedTestFiles, x)); |
| 635 | |
| 636 | testFiles = updatedTestFiles; |
| 637 | |
| 638 | // When file renamed (created / deleted) we need to update the watcher |
| 639 | if (newFileName) { |
| 640 | owners = new SafeSet().add(newFileName); |
| 641 | const resolveFileName = isAbsolute(newFileName) ? newFileName : resolve(opts.cwd, newFileName); |
| 642 | watcher.filterFile(resolveFileName, owners); |
| 643 | } |
| 644 | |
| 645 | if (!newFileName && previousFileName) { |
| 646 | return; // Avoid rerunning files when file deleted |
| 647 | } |
| 648 | } |
| 649 | // Reset the root start time to recalculate the duration |
| 650 | // of the run |
| 651 | opts.root.clearExecutionTime(); |
| 652 | opts.root.reporter[kEmitMessage]('test:watch:restarted'); |
| 653 | |
| 654 | // Restart test files |
| 655 | if (opts.isolation === 'none') { |
| 656 | PromisePrototypeThen(restartTestFile(kIsolatedProcessName), undefined, (error) => { |
| 657 | triggerUncaughtException(error, true /* fromPromise */); |
| 658 | }); |
| 659 | } else { |
| 660 | watcher.unfilterFilesOwnedBy(owners); |
| 661 | PromisePrototypeThen(SafePromiseAllReturnVoid(testFiles, async (file) => { |
| 662 | if (!owners.has(file)) { |
| 663 | return; |
| 664 | } |
| 665 | |
| 666 | await restartTestFile(file); |
| 667 | }, undefined, (error) => { |
| 668 | triggerUncaughtException(error, true /* fromPromise */); |
| 669 | })); |
| 670 | } |
| 671 | }; |
| 672 | |
| 673 | watcher.on('changed', onChanged); |
| 674 |
nothing calls this directly
no test coverage detected
searching dependent graphs…