Skip to content

Commit

Permalink
use hasteFS.getSize in TestSequencer
Browse files Browse the repository at this point in the history
  • Loading branch information
jeysal committed Jan 6, 2019
1 parent 0597593 commit 8b3cf0a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/jest-cli/src/TestSequencer.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ export default class TestSequencer {
// fastest results.
sort(tests: Array<Test>): Array<Test> {
const stats = {};
const fileSize = test =>
stats[test.path] || (stats[test.path] = fs.statSync(test.path).size);
const fileSize = ({path, context: {hasteFS}}) =>
stats[path] || (stats[path] = hasteFS.getSize(path) || 0);
const hasFailed = (cache, test) =>
cache[test.path] && cache[test.path][0] === FAIL;
const time = (cache, test) => cache[test.path] && cache[test.path][1];
Expand Down
7 changes: 6 additions & 1 deletion packages/jest-cli/src/__tests__/test_sequencer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ const context = {
cacheDirectory: '/cache',
name: 'test',
},
hasteFS: {
getSize: path => path.length,
},
};

const secondContext = {
Expand All @@ -31,6 +34,9 @@ const secondContext = {
cacheDirectory: '/cache2',
name: 'test2',
},
hasteFS: {
getSize: path => path.length,
},
};

const toTests = paths =>
Expand All @@ -45,7 +51,6 @@ beforeEach(() => {

fs.readFileSync = jest.fn(() => '{}');
fs.existsSync = () => true;
fs.statSync = jest.fn(filePath => ({size: filePath.length}));
fs.writeFileSync = jest.fn();
});

Expand Down

0 comments on commit 8b3cf0a

Please sign in to comment.