-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dev: ESLint run on largest files first [fix]
- Loading branch information
1 parent
f519704
commit f43f8e6
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* -------------------- | ||
* livepack | ||
* Custom test sequencer for Jest ESLint | ||
* ------------------*/ | ||
|
||
'use strict'; | ||
|
||
// Modules | ||
const fs = require('fs'), | ||
Sequencer = require('@jest/test-sequencer').default; | ||
|
||
// Exports | ||
|
||
// Custom sequencer to ensure the largest files are run first. | ||
// `jest-runner-eslint` doesn't seem to sequence automatically. | ||
// https://github.com/jest-community/jest-runner-eslint/issues/204 | ||
// TODO: Remove this workaround once above issue is fixed. | ||
|
||
module.exports = class CustomSequencer extends Sequencer { | ||
sort(tests) { | ||
tests = super.sort(tests); | ||
const testsWithFileSizes = tests.map(test => ({test, size: fs.statSync(test.path).size})); | ||
testsWithFileSizes.sort((t1, t2) => (t1.size > t2.size ? -1 : t1.size < t2.size ? 1 : 0)); | ||
return testsWithFileSizes.map(({test}) => test); | ||
} | ||
}; |