Skip to content

Commit

Permalink
fix: jest tests file key from hash
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed May 16, 2021
1 parent d1f09ef commit ea481bd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
6 changes: 3 additions & 3 deletions core/instrument/src/misc/chached-file.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as fs from 'fs';
import * as path from 'path';
import * as os from 'os';
import fs from 'fs';
import path from 'path';
import os from 'os';
import { createHash } from 'crypto';
import findCacheDir from 'find-cache-dir';

Expand Down
14 changes: 12 additions & 2 deletions core/instrument/src/misc/jest-tests.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import path from 'path';
import fs from 'fs';
import { createHash } from 'crypto';
import {
JestConfig,
runProjectTests,
Expand Down Expand Up @@ -36,12 +37,21 @@ export const extractTests = async (
return '';
})
.filter(f => f);
const cached = new CachedFileResource<JestTests>('jest-tests', testFiles[0], [
const allFiles = [
...testFiles,
...coverageFiles,
...snapshotFiles,
...trackFiles,
]);
];
const fileHash = allFiles
.reduce((acc, f) => acc.update(f), createHash('md5'))
.digest('hex');

const cached = new CachedFileResource<JestTests>(
'jest-tests',
fileHash,
allFiles,
);
const cachedResults = cached.get();
if (cachedResults) {
return cachedResults;
Expand Down

0 comments on commit ea481bd

Please sign in to comment.