Skip to content

Commit

Permalink
Run tests immediately on start up when using --watch or --watchAll
Browse files Browse the repository at this point in the history
  • Loading branch information
xadn committed Aug 19, 2016
1 parent 9dc6cc4 commit 2e734c1
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions packages/jest-cli/src/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,18 @@ function runCLI(argv: Object, root: Path, onComplete: () => void) {
getWatcher(config, root, watcher => {
let timer;
let isRunning;
const startRun = () => {
isRunning = true;
runJest(config, argv, pipe, () => isRunning = false)
.then(
resolve,
error => console.error(chalk.red(error)),
);
};

pipe.write(CLEAR);
startRun();

watcher.on('all', (_, filePath) => {
pipe.write(CLEAR);
filePath = path.join(root, filePath);
Expand All @@ -170,17 +180,7 @@ function runCLI(argv: Object, root: Path, onComplete: () => void) {
clearTimeout(timer);
timer = null;
}
timer = setTimeout(
() => {
isRunning = true;
runJest(config, argv, pipe, () => isRunning = false)
.then(
resolve,
error => console.error(chalk.red(error)),
);
},
WATCHER_DEBOUNCE,
);
timer = setTimeout(startRun, WATCHER_DEBOUNCE);
}
});
});
Expand Down

0 comments on commit 2e734c1

Please sign in to comment.