Comments (10)
I was able to find some time for this in the past few days, turns out its a little bit tricky to re-write a jest.confg.js
file in a responsible way as opposed to a jest.config.json
, simply because I can't just assume that file is
module.exports = {
// config
}
It may be something like:
const cleverConfigLogicBasedOnEnv = {
// ...
}
module.exports = {
...cleverConfigLogicBasedOnEnv,
// rest of config
}
Certainly it can be done, it will just take some regexs and logic that will have to evolve over time as edge cases come up. With this in mind, I think the first pass will just support jest.config.json
files while some thought is put into how to effectively deal with .js
.
As a workaround until then, you could make a file called something like jest.coverageConfig.json
that was there just for the purpose of ratcheting, then import that and spread it into your jest.config.js
jest.coverageConfig.json
{
"coverageThreshold": {
"global": {
"lines": 86.67,
"statements": 74.29,
"functions": 10,
"branches": 50
}
}
}
jest.config.js
const coverageConfig = require('./jest.coverageConfig.json')
module.exports = {
...coverageConfig,
// rest of your config
}
then just make sure that you are running the command like
jest-coverage-ratchet --configPath ./jest.coverageConfig.json
from jest-coverage-ratchet.
There is a new package based on jest-coverage-ratchet
that will do this that is still being maintained called jest-coverage-thresholds-bumper
.
https://github.com/Litee/jest-coverage-thresholds-bumper
from jest-coverage-ratchet.
Well its cool to see that someone is using this 😅 I will try to get this done in the PM hours this week, I haven't used it in my daily work for a few years so it had just left my mental inbox so to speak :)
from jest-coverage-ratchet.
I found a workaround for this using the current version;
TL;DR import the thresholds directly from
package.json
npm i -D jest-coverage-ratchet
- add to package.json:
{
"scripts": {
"test:coverage": "jest-coverage-ratchet",
}
}
npm run test:coverage
(package.json
now contains"jest": {}
)- update
jest.config.js
:
const jestConfig = require('./package.json').jest;
module.exports = {
...jestConfig,
}
from jest-coverage-ratchet.
This is a pretty common case and worth supporting 👍
from jest-coverage-ratchet.
@Koleok any update on this?
from jest-coverage-ratchet.
@SimplyComplexable doesn't look any new PR was closed recently.
from jest-coverage-ratchet.
I would love this feature.
from jest-coverage-ratchet.
Hi @Koleok !
Just wanted to note next
simply because I can't just assume that file is...
thats true. different setups are possible.
However, in readme you already do some assumptions
I know what happens when you assume, but jest-coverage-ratchet makes the following assumptions about your project.
I would ask you to make one more.
BTW thanks for great lib
from jest-coverage-ratchet.
@ZuBB Fair enough 👌 , lets give it a try with that assumption, seems there are few enough users of this lib that its not a crazy experiment to assume a certain format of jest.config.js, I'll push up the new version over the next few days with that packed in 👍
from jest-coverage-ratchet.
Related Issues (9)
- allow different configuration file
- Command returns empty object as new coverage thresholds HOT 1
- allow different path for coverage path HOT 1
- How does it work? HOT 2
- Not working with categories
- Is there a mechanism to check the previously ran thresholds HOT 1
- thresholds updated in package.json when --configPath is provided HOT 2
- Rounding coverage values down HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jest-coverage-ratchet.