Comparing version 0.5.5 to 0.5.6
@@ -0,1 +1,7 @@ | ||
## 0.5.6 | ||
* Cache test run performance and run slowest tests first to maximiz worker | ||
utilization | ||
* Update to jsdom 6.5.0 | ||
## 0.5.5 | ||
@@ -2,0 +8,0 @@ |
{ | ||
"name": "jest-cli", | ||
"description": "Painless JavaScript Unit Testing.", | ||
"version": "0.5.5", | ||
"version": "0.5.6", | ||
"main": "src/jest.js", | ||
@@ -14,3 +14,3 @@ "dependencies": { | ||
"jasmine-pit": "^2.0.2", | ||
"jsdom": "6.3.0", | ||
"jsdom": "6.5.0", | ||
"lodash.template": "^3.6.2", | ||
@@ -17,0 +17,0 @@ "node-haste": "^1.2.8", |
@@ -197,3 +197,3 @@ /** | ||
this._formatMsg( | ||
'Waiting on ' + remainingTests + ' ' + pluralTests + '...', | ||
'Running ' + remainingTests + ' ' + pluralTests + '...', | ||
colors.GRAY + colors.BOLD | ||
@@ -200,0 +200,0 @@ ) |
@@ -91,2 +91,6 @@ /** | ||
); | ||
// Map from testFilePath -> time it takes to run the test. Used to | ||
// optimally schedule bigger test runs. | ||
this._testPerformanceCache = null; | ||
this._opts = assign({}, DEFAULT_OPTIONS, options); | ||
@@ -401,2 +405,67 @@ } | ||
TestRunner.prototype._getTestPerformanceCachePath = function() { | ||
return path.join( | ||
this._config.cacheDirectory, | ||
'perf-cache-' + this._config.name | ||
); | ||
}; | ||
TestRunner.prototype._sortTests = function(testPaths) { | ||
// When running more tests than we have workers available, sort the tests | ||
// by size - big test files usually take longer to complete, so we run | ||
// them first in an effort to minimize worker idle time at the end of a | ||
// long test run. | ||
// | ||
// After a test run we store the time it took to run a test and on | ||
// subsequent runs we use that to run the slowest tests first, yielding the | ||
// fastest results. | ||
try { | ||
this._testPerformanceCache = JSON.parse(fs.readFileSync( | ||
this._getTestPerformanceCachePath() | ||
)); | ||
} catch (e) {} | ||
var testPerformanceCache = this._testPerformanceCache; | ||
if (testPaths.length > this._opts.maxWorkers) { | ||
testPaths = testPaths | ||
.map(path => [path, fs.statSync(path).size]) | ||
.sort(function(a, b) { | ||
const cacheA = testPerformanceCache && testPerformanceCache[a[0]]; | ||
const cacheB = testPerformanceCache && testPerformanceCache[b[0]]; | ||
if (cacheA !== null && cacheB !== null) { | ||
return cacheA < cacheB ? 1 : -1; | ||
} | ||
return a[1] < b[1] ? 1 : -1; | ||
}) | ||
.map(function(p) { | ||
return p[0]; | ||
}); | ||
} | ||
return testPaths; | ||
}; | ||
TestRunner.prototype._cacheTestResults = function(aggregatedResults) { | ||
var performanceCacheFile = this._getTestPerformanceCachePath(); | ||
var testPerformanceCache = this._testPerformanceCache; | ||
if (!testPerformanceCache) { | ||
testPerformanceCache = this._testPerformanceCache = {}; | ||
} | ||
aggregatedResults.testResults.forEach(function(test) { | ||
const perf = test && test.perfStats; | ||
if (perf && perf.end && perf.start) { | ||
testPerformanceCache[test.testFilePath] = perf.end - perf.start; | ||
} | ||
}); | ||
return new Promise(function(resolve) { | ||
fs.writeFile( | ||
performanceCacheFile, | ||
JSON.stringify(testPerformanceCache), | ||
function() { | ||
resolve(aggregatedResults); | ||
} | ||
); | ||
}); | ||
}; | ||
/** | ||
@@ -422,2 +491,4 @@ * Run all given test paths. | ||
testPaths = this._sortTests(testPaths); | ||
var aggregatedResults = { | ||
@@ -467,7 +538,11 @@ success: null, | ||
return testRun.then(function() { | ||
aggregatedResults.success = aggregatedResults.numFailedTests === 0; | ||
reporter.onRunComplete && reporter.onRunComplete(config, aggregatedResults); | ||
return aggregatedResults; | ||
}); | ||
return testRun | ||
.then(function() { | ||
aggregatedResults.success = aggregatedResults.numFailedTests === 0; | ||
if (reporter.onRunComplete) { | ||
reporter.onRunComplete(config, aggregatedResults); | ||
} | ||
return aggregatedResults; | ||
}) | ||
.then(this._cacheTestResults.bind(this)); | ||
}; | ||
@@ -474,0 +549,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
357981
69
9300
+ Addedjsdom@6.5.0(transitive)
- Removedacorn@1.2.2(transitive)
- Removedjsdom@6.3.0(transitive)
- Removedtough-cookie@1.2.0(transitive)
Updatedjsdom@6.5.0