forked from facebook/react
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Track passing/failing tests in fiber (facebook#8169)
* Work around jest toEqual bug in ReactTreeTraversal ![image](https://cloud.githubusercontent.com/assets/6820/19879640/1cd7595a-9fb2-11e6-94ac-8c38bdfc90d3.png) * Track passing/failing tests in fiber Run scripts/fiber/record-tests to re-record, then check git diff to see what you changed.
- Loading branch information
1 parent
abeae30
commit 08b4cc5
Showing
7 changed files
with
1,952 additions
and
32 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
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,73 @@ | ||
#!/usr/bin/env node | ||
|
||
const fs = require('fs'); | ||
const os = require('os'); | ||
const path = require('path'); | ||
|
||
const SearchSource = require('jest').SearchSource; | ||
const TestRunner = require('jest').TestRunner; | ||
|
||
const createHasteContext = require('jest-runtime').createHasteContext; | ||
const readConfig = require('jest-config').readConfig; | ||
|
||
const argv = {}; | ||
const root = path.normalize(path.join(__dirname, '..', '..')); | ||
const testPathPattern = ''; | ||
|
||
function runJest() { | ||
return readConfig(argv, root) | ||
.then((config) => { | ||
return createHasteContext(config, {}).then((hasteMap) => { | ||
const source = new SearchSource(hasteMap, config); | ||
return source.getTestPaths({testPathPattern}) | ||
.then((data) => { | ||
const runner = new TestRunner( | ||
hasteMap, | ||
config, | ||
{ | ||
maxWorkers: Math.max(os.cpus().length - 1, 1), | ||
getTestSummary: () => 'You did it!' | ||
} | ||
); | ||
return runner.runTests(data.paths); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
function formatResults(runResults, predicate) { | ||
const formatted = []; | ||
runResults.testResults.forEach((fileResult) => { | ||
const file = path.relative(root, fileResult.testFilePath); | ||
const tests = fileResult.testResults.filter( | ||
(test) => predicate(fileResult, test) | ||
); | ||
if (tests.length) { | ||
const lines = [file].concat(tests.map((test) => '* ' + test.title)); | ||
formatted.push(lines.join('\n')); | ||
} | ||
}); | ||
formatted.sort(); | ||
return formatted.join('\n\n'); | ||
} | ||
|
||
process.env.REACT_DOM_JEST_USE_FIBER = true; | ||
runJest() | ||
.then((runResults) => { | ||
const passing = formatResults( | ||
runResults, | ||
(file, test) => test.status === 'passed' | ||
); | ||
const failing = formatResults( | ||
runResults, | ||
(file, test) => test.status === 'failed' | ||
); | ||
fs.writeFileSync( | ||
path.join(__dirname, 'tests-passing.txt'), | ||
passing + '\n' | ||
); | ||
fs.writeFileSync( | ||
path.join(__dirname, 'tests-failing.txt'), | ||
failing + '\n' | ||
); | ||
}); |
Oops, something went wrong.