Comments (5)
@viveleroi c8 doesn't work with TS, because Node.js doesn't support TS. So, please provide .js source which is not covered, or complete setup (tsconfig, etc.) to reproduce it.
from c8.
It's marking the as const
portion of this code snipped as "function not covered":
export const QueryModeValues = ['button', 'live'] as const
type QueryModes = (typeof QueryModeValues)[number]
We're using vite and configs are pretty standard, only real changes are the base url, paths, includes. Our tsconfig.json
:
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"baseUrl": "app",
"paths": {
"@/*": ["./app/*"]
}
},
"include": ["app", "./tests/components/setup.ts", ".storybook/*.ts"],
"references": [{ "path": "./tsconfig.node.json" }]
}
from c8.
@viveleroi it's a bit funny because you have 'noEmit: true' in tsconfig ) Sourcemaps are not enabled too. Ok, lets add all necessary things:
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "react-jsx",
"sourceMap": true
}
}
Then create 1.ts:
export const QueryModeValues = ["button", "live"] as const;
// some code to ensure that source maps are avalid
const x: string = "lalala";
console.log(x);
Run 'yarn tsc && yarn c8 --all --include '*.js' --reporter text --reporter html node 1.js' (latest package versions, latest node)
100% coverage, as you can see
PS forget to use '--enable-source-maps' node option because I have it enabled globally.
from c8.
I don't appreciate being told my issue is funny, these configs are essentially unchanged (paths only, I didn't touch emit) from what vite created so don't act like this is my mistake. Vitest is our test runner and they're using c8 for coverage, I'm not going to run this tool outside of those packages.
from c8.
Sure, I mean only provided configuration is funny, not the problem itself - which is may be very annoying and frustrating.
BTW, we found one fact: in given setup c8 works correctly with 'as const' statements. Obvious assumption - the issue is somewhere between your code and c8.
You can try to create vitest issue, or provide minimal repo here. Without your particular setup it's impossible to find issue 'somewhere around vitest'.
from c8.
Related Issues (20)
- Improve code quality by increasing code coverage. HOT 1
- Running tests with coverage causes CPU to hit 100% after tests finish HOT 17
- Why are reports generated when tests fail? HOT 1
- Should we have an `eslint-plugin-c8`?
- No coverage when using self-references HOT 2
- Empty lcov if source code using `.mts`
- If excludeAfterRemap is enabled, the coverage stats become constant 100
- c8 report is directed to coverage/root which cant be resolved
- Context-insensitive parsing of sourceMappingURL
- [feat] `report-unused-ignore-directives`
- Collecting coverage within VM HOT 1
- `if`, `while`, etc. body without braces not always reported in `% Stmts`, `% Lines`, or `Uncovered Line #s`
- c8 crashes when encountering data:text/javascript;base64 URLs
- Security finding in c8 versions 6, 7, and 8 HOT 1
- Testing Angular 11.x web appliaction with 0 coverage HOT 1
- Path contains invalid characters
- only % branch and % funcs are ignored, not % stmts or % lines
- Merge the results of different testing tools and report it (Read report from lcov.info instead of json files) HOT 1
- c8 upgrade from 8.0.0 to 8.0.1 seems to break --exclude on Windows when value is single-quoted in npm script HOT 13
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 c8.