-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: find missing files when using all:true option (#208)
* add example where a file should not be covered * find files to include using globby * insert empty coverage for missed files * refactor a little * change the icon for files without any statements * confirm file not-covered is present in the final report * search using default extension masks if include is not present
- Loading branch information
Showing
20 changed files
with
292 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// @ts-check | ||
function combineNycOptions({ | ||
pkgNycOptions, | ||
nycrc, | ||
nycrcJson, | ||
defaultNycOptions | ||
}) { | ||
// last option wins | ||
const nycOptions = Object.assign( | ||
{}, | ||
defaultNycOptions, | ||
nycrc, | ||
nycrcJson, | ||
pkgNycOptions | ||
) | ||
|
||
if (typeof nycOptions.reporter === 'string') { | ||
nycOptions.reporter = [nycOptions.reporter] | ||
} | ||
if (typeof nycOptions.extension === 'string') { | ||
nycOptions.extension = [nycOptions.extension] | ||
} | ||
|
||
return nycOptions | ||
} | ||
|
||
const defaultNycOptions = { | ||
'report-dir': './coverage', | ||
reporter: ['lcov', 'clover', 'json'], | ||
extension: ['.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx'], | ||
excludeAfterRemap: true | ||
} | ||
|
||
module.exports = { | ||
combineNycOptions, | ||
defaultNycOptions | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"plugins": ["istanbul"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# example: all files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"fixturesFolder": false, | ||
"baseUrl": "http://localhost:1234" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/// <reference types="cypress" /> | ||
it('works', () => { | ||
cy.visit('/') | ||
cy.contains('Page body') | ||
|
||
cy.window() | ||
.invoke('reverse', 'super') | ||
.should('equal', 'repus') | ||
|
||
// application's code should be instrumented | ||
cy.window().should('have.property', '__coverage__') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = (on, config) => { | ||
require('../../../../task')(on, config) | ||
on('file:preprocessor', require('../../../../use-babelrc')) | ||
return config | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import '../../../../support' | ||
console.log('this is commands file') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require('./commands') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<body> | ||
Page body | ||
<script src="main.js"></script> | ||
<script src="second.js"></script> | ||
<script> | ||
// use functions creates in "main.js" | ||
if (add(2, 3) !== 5) { | ||
throw new Error('wrong addition') | ||
} | ||
if (sub(2, 3) !== -1) { | ||
throw new Error('wrong subtraction') | ||
} | ||
if (reverse('foo') !== 'oof') { | ||
throw new Error('wrong string reverse') | ||
} | ||
</script> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
window.add = (a, b) => a + b | ||
|
||
window.sub = (a, b) => a - b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// this file is NOT included from "index.html" | ||
// thus it is not instrumented and not included | ||
// in the final code coverage numbers | ||
function throwsError() { | ||
throw new Error('NO') | ||
} | ||
throwsError() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "example-all-files", | ||
"description": "Report all files", | ||
"scripts": { | ||
"start": "../../node_modules/.bin/parcel serve index.html", | ||
"cy:open": "../../node_modules/.bin/cypress open", | ||
"cy:run": "../../node_modules/.bin/cypress run", | ||
"dev": "../../node_modules/.bin/start-test 1234 cy:open", | ||
"e2e": "../../node_modules/.bin/start-test 1234 cy:run", | ||
"report": "../../node_modules/.bin/nyc report" | ||
}, | ||
"nyc": { | ||
"all": true, | ||
"include": "*.js" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "7.9.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// this file should be excluded from the final coverage numbers | ||
// using "nyc.exclude" list in package.json | ||
window.reverse = s => | ||
s | ||
.split('') | ||
.reverse() | ||
.join('') |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.