Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utils: testCoverage calculation #74

Open
tunnckoCore opened this issue Nov 1, 2019 · 0 comments
Open

utils: testCoverage calculation #74

tunnckoCore opened this issue Nov 1, 2019 · 0 comments
Labels
good first issue Good for newcomers and first-timer contributors Pkg: @tunnckocore/utils Priority: Low This issue can probably be picked up by anyone looking to contribute to the project. Status: Available No one has claimed for resolving this issue. Generally applied to bugs and enhancement issues. Type: Enhancement Most issues will probably be for additions or changes. Expected that this will result in a PR.

Comments

@tunnckoCore
Copy link
Owner

This one here

const res = Object.keys(files)
.filter((key) => key.startsWith(pkgRoot))
.map((filename) => files[filename]);
if (res.length > 1) {
value = res.reduce(
(accumulator, item) => {
accumulator.statements += item.statements / res.length;
accumulator.branches += item.branches / res.length;
accumulator.functions += item.functions / res.length;
accumulator.lines += item.lines / res.length;
return accumulator;
},
{ statements: 0, branches: 0, functions: 0, lines: 0 },
);
}
const cov = Object.keys(value).reduce(
(accum, typeName) => accum + value[typeName],
0,
);

The other way to calc is to sum all:

item.statements + item.branches + item.functions + item.lines

and then divide it by the res.length

Still not sure. But it's probably the same, or I'm sleepy.

@tunnckoCore tunnckoCore added Type: Enhancement Most issues will probably be for additions or changes. Expected that this will result in a PR. good first issue Good for newcomers and first-timer contributors Priority: Low This issue can probably be picked up by anyone looking to contribute to the project. Status: Available No one has claimed for resolving this issue. Generally applied to bugs and enhancement issues. Pkg: @tunnckocore/utils labels Nov 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers and first-timer contributors Pkg: @tunnckocore/utils Priority: Low This issue can probably be picked up by anyone looking to contribute to the project. Status: Available No one has claimed for resolving this issue. Generally applied to bugs and enhancement issues. Type: Enhancement Most issues will probably be for additions or changes. Expected that this will result in a PR.
Projects
None yet
Development

No branches or pull requests

1 participant