markis / jest-ratchet Goto Github PK
View Code? Open in Web Editor NEWđ§ Ratchet up test coverage
Home Page: https://www.npmjs.com/jest-ratchet
License: MIT License
đ§ Ratchet up test coverage
Home Page: https://www.npmjs.com/jest-ratchet
License: MIT License
Error: watch /coverage ENOENT
[0] at exports._errnoException (util.js:1020:11)
[0] at FSWatcher.start (fs.js:1451:19)
[0] at Object.fs.watch (fs.js:1478:11)
[0] at JestRatchet.onRunComplete (/node_modules/jest-ratchet/index.js:118:28)
[0] at /node_modules/jest-cli/build/ReporterDispatcher.js:62:24
[0] at next (native)
[0] at step (/node_modules/jest-cli/build/ReporterDispatcher.js:1:260)
[0] at /node_modules/jest-cli/build/ReporterDispatcher.js:1:420
[0] at process._tickCallback (internal/process/next_tick.js:109:7)
When jest executes onRunComplete
coverage hasn't be evaluated yet, so the new coverage summary hasn't been written to the file.
Maybe there should be a watcher that watches for the coverage to get updated and then updates the threshold after the new coverage has been written.
Is it possible to use jest-ratchet when you have glob coverageThresholds setup along with global thresholds, currently I am not seeing thresholds update when using glob patterns
example:
"./src/util": {
"functions": 70,
"lines": 70,
"statements": 70
}
đ¨ You need to enable Continuous Integration on all branches of this repository. đ¨
To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.
Since we didnât receive a CI status on the greenkeeper/initial
branch, itâs possible that you donât have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.
If you have already set up a CI for this repository, you might need to check how itâs configured. Make sure it is set to run on all new branches. If you donât want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/
.
Once you have installed and configured CI on this repository correctly, youâll need to re-trigger Greenkeeperâs initial pull request. To do this, please delete the greenkeeper/initial
branch in this repository, and then remove and re-add this repository to the Greenkeeper Appâs white list on Github. You'll find this list on your repo or organizationâs settings page, under Installed GitHub Apps.
In jest config, we can define multiple paths under "coverageThreshold" and although jest checks for these coverages, jest-ratchet does not update these values.
Is this something which is already supported? If not, I have done these changes locally on my project and would love to create a PR for the same in this project to add the support.
I'm using vscode-jest to automatically run related tests as files are changed. It has the unwanted side effect of updating the coverage to reflect only the changed files. Jest-ratchet has no way of knowing it's a partial coverage report, so it updates the global threshold to reflect the partial result.
In the midst of filing a bug I found a work-around: add the following to VSCode's settings.json.
{
"jest.pathToJest": "node_modules/.bin/jest --no-coverage --reporters=default"
}
I'll just leave this here for reference. :)
Jest-ratchet should have an option for where it will stop updating the threshold. Project could potentially have an acceptable threshold of 80 and whenever it reaches that point then ratchet will no longer change the threshold.
For example, by default jest-ratchet would ratchet results, but if I were to run jest --disable-ratchet
it wouldn't ratchet the results and the results would remain the same.
I just installed jest-ratchet and I'm getting the following error.
Error: An error occurred while adding the reporter at path "/code/omega/node_modules/jest-ratchet/index.js"._inplace is not defined
at reporters.forEach (/code/omega/node_modules/jest/node_modules/jest-cli/build/TestScheduler.js:510:15)
at Array.forEach (<anonymous>)
at TestScheduler._addCustomReporters (/code/omega/node_modules/jest/node_modules/jest-cli/build/TestScheduler.js:497:15)
at TestScheduler._setupReporters (/code/omega/node_modules/jest/node_modules/jest-cli/build/TestScheduler.js:466:12)
at new TestScheduler (/code/omega/node_modules/jest/node_modules/jest-cli/build/TestScheduler.js:193:10)
at /code/omega/node_modules/jest/node_modules/jest-cli/build/runJest.js:452:27
at Generator.next (<anonymous>)
at step (/code/omega/node_modules/jest/node_modules/jest-cli/build/runJest.js:107:30)
at /code/omega/node_modules/jest/node_modules/jest-cli/build/runJest.js:118:15
The source is this line in index.js.
var inplace = _inplace;
It seems to come down to the fact that json-in-place
is external in the Rollup config. The change happened in this 19c6c95.
I can fix it by manually editing the index.js. There's another line further down where I had to do the same thing for yargs_parser.
var inplace = require('json-in-place');
This works, but manually editing a file in node_modules isn't a solution. I could send a PR with the updated .js file, but it's just going to get broken again the next time a build is run. I'm guessing something needs to be changed in the Rollup or TypeScript config.
In the meantime, this library seems to be working for others. Maybe I'm just doing something wrong?
To reproduce, use the following config:
âcoverageThresholdâ: {
âglobalâ: {
âbranchesâ: 0,
âlinesâ: 0,
âfunctionsâ: 0,
âstatementsâ: 0
}
}
Expected result:
coverageThreshold values are ratcheted up to the actual coverage values
Actual result:
coverageThreshold values are unchanged
There's an issue when no coverage directory exists yet and a freshly cloned repository is executing its first test run. I've been observing that specifically on Mac OS X, the onSummaryReportComplete
function is being invoked by the fs.watch
handler for the coverage directory before Jest completes the test run. This piece of code in the onRunComplete
function is creating an empty file, coverage-summary.json
.
if (!fs.existsSync(coverageSummaryPath)) {
fs.closeSync(fs.openSync(coverageSummaryPath, 'w'));
}
The watch handler is getting invoked as a result despite the fact that the "watch" is put in place after the file is created. This results in an SyntaxError: Unexpected end of JSON input
error upon exiting the test run.
When I remove this piece of code, everything works as expected even when I completely remove the coverage
directory prior to run tests.
Is it necessary to create this file?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
đ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. đđđ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google â¤ď¸ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.