Skip to content

Commit

Permalink
fix(coverage): get too 100% test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Feb 17, 2018
1 parent 6f2256b commit d56a0ed
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ script:
- yarn commitlint --from="$TRAVIS_BRANCH" --to="$TRAVIS_COMMIT"
- yarn commitlint --from=$TRAVIS_COMMIT
- yarn prettylint
- yarn test
- yarn test --coverage
after_script: greenkeeper-lockfile-upload
jobs:
include:
Expand Down
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@
"*.{md,json}": ["prettier --write", "git add"]
},
"jest": {
"coverageThreshold": {
"global": {
"branches": 96,
"functions": 97,
"lines": 99,
"statements": 99
}
},
"projects": [
{
"displayName": "test",
Expand Down
6 changes: 6 additions & 0 deletions rules/__tests__/no-disabled-tests.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ ruleTester.run('no-disabled-tests', rule, {
'test.only("foo", function () {})',
'var appliedSkip = describe.skip; appliedSkip.apply(describe)',
'var calledSkip = it.skip; calledSkip.call(it)',
'({ f: function () {} }).f()',
'(a || b).f()',
],

invalid: [
Expand Down Expand Up @@ -80,6 +82,10 @@ ruleTester.run('no-disabled-tests', rule, {
{ message: 'Call to pending() within test', column: 48, line: 1 },
],
},
{
code: 'pending();',
errors: [{ message: 'Call to pending()', column: 1, line: 1 }],
},
{
code: 'describe("contains a call to pending", function () { pending() })',
errors: [
Expand Down
5 changes: 5 additions & 0 deletions rules/no-disabled-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ module.exports = {
message: 'Call to pending() within test suite',
node,
});
} else {
context.report({
message: 'Call to pending()',
node,
});
}
break;

Expand Down
3 changes: 2 additions & 1 deletion rules/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,15 @@ const isFunction = node =>
* package version to build the link to a tagged version of the
* documentation file.
*
* @param {string} ruleName - Name of the eslint rule
* @param {string} filename - Name of the eslint rule
* @returns {string} URL to the documentation for the given rule
* @throws {Error} If the documentation file for the given rule is not present.
*/
const getDocsUrl = filename => {
const ruleName = path.basename(filename, '.js');

const docsFile = path.join(__dirname, `../docs/rules/${ruleName}.md`);
// istanbul ignore if
if (!fs.existsSync(docsFile)) {
throw new Error(`Could not find documentation file for rule "${ruleName}"`);
}
Expand Down

0 comments on commit d56a0ed

Please sign in to comment.