( state: RunnerState, onChange: (state: RunnerState) => void, )
| 120 | }; |
| 121 | |
| 122 | function subscribeFixtures( |
| 123 | state: RunnerState, |
| 124 | onChange: (state: RunnerState) => void, |
| 125 | ) { |
| 126 | // Watch the fixtures directory for changes |
| 127 | watcher.subscribe(FIXTURES_PATH, async (err, _events) => { |
| 128 | if (err) { |
| 129 | console.error(err); |
| 130 | process.exit(1); |
| 131 | } |
| 132 | // Try to ignore changes that occurred as a result of our explicitly updating |
| 133 | // fixtures in update(). |
| 134 | // Currently keeps a timestamp of last known changes, and ignore events that occurred |
| 135 | // around that timestamp. |
| 136 | const isRealUpdate = performance.now() - state.lastUpdate > 5000; |
| 137 | if (isRealUpdate) { |
| 138 | // Fixtures changed, re-run tests |
| 139 | state.mode.action = RunnerAction.Test; |
| 140 | onChange(state); |
| 141 | } |
| 142 | }); |
| 143 | } |
| 144 | |
| 145 | function subscribeFilterFile( |
| 146 | state: RunnerState, |
no test coverage detected