Skip to content

Commit

Permalink
Merge c32f38a into 256bd51
Browse files Browse the repository at this point in the history
  • Loading branch information
markis committed Feb 1, 2018
2 parents 256bd51 + c32f38a commit 06ba11b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions __mocks__/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function watch() {

fs.__addMockFile = __addMockFile;
fs.__resetMockFiles = __resetMockFiles;
fs.existsSync = function() { return false; };
fs.readFileSync = readFileSync;
fs.watch = watch;

Expand Down
9 changes: 8 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readFileSync, watch } from 'fs';
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, watch } from 'fs';

import { getLastError } from './errors';
import {
Expand Down Expand Up @@ -34,6 +34,13 @@ function onRunComplete(globalConfig: Config, options: RatchetOptions) {
const coverageSummaryPath = findCoverageSummaryPath(coverageDirectory);
const jestConfigPath = findJestConfigPath(process.cwd(), process.argv);

if (!existsSync(coverageDirectory)) {
mkdirSync(coverageDirectory);
}
if (!existsSync(coverageSummaryPath)) {
closeSync(openSync(coverageSummaryPath, 'w'));
}

const watcher = watch(coverageDirectory);
watcher.once('change', () => {
watcher.close();
Expand Down
1 change: 1 addition & 0 deletions src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ describe('jest-ratchet', () => {
/\/jestconfig\.json$/,
JSON.stringify({ ...threshold }),
);
fs.existsSync = () => true;

const jestRatchet = new JestRatchet({ ...mockConfig, ...threshold });
jestRatchet.onRunComplete();
Expand Down

0 comments on commit 06ba11b

Please sign in to comment.