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

Add a coverage export that gets the code coverage of a particular module #4

Open
Vehmloewff opened this issue Sep 13, 2023 · 1 comment

Comments

@Vehmloewff
Copy link
Owner

This can be done by running deno test with the --coverage option. You can then get a doc view of the target module, determine which files are included, and, if they are not in the coverage, include those with a coverage of 0%.

Advanced
Do this all on a function/by/function basis

@Vehmloewff
Copy link
Owner Author

Some starter code I wrote in a coverage.ts file:

export async function getCoverage(entryPoint: string): Promise<void> {
	const files = await readDir('code_cov')

	for (const file of files) {
		const contents = await readJson(pathUtils.join('code_cov', file))
		if (!contents.url.startsWith('file://')) continue

		for (const func of contents.functions) {
			console.log(contents.url, func)
		}
	}
}

await getCoverage('foo')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant