-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(no-pending-tests): add rule to disallow pending specs
- Loading branch information
1 parent
596d706
commit ab30e3e
Showing
5 changed files
with
90 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Disallow use of pending tests (no-pending-tests) | ||
|
||
Jasmine uses `pending` ("[pending specs][]") to mark a spec | ||
as not implemented yet. | ||
|
||
`pending` should only be used when creating a test suite skeleton. | ||
|
||
[pending specs]: https://jasmine.github.io/api/3.5/global.html#pending | ||
|
||
## Rule details | ||
|
||
This rule triggers a **warning** (is set to **1** by default) whenever it | ||
encounters `pending`. | ||
|
||
The following patterns are considered warnings: | ||
|
||
```js | ||
it('My pending spec', function() { pending('I am pending'); }); | ||
|
||
describe('My suite', function() { | ||
it('My pending spec', function() { | ||
pending('I am pending'); | ||
}); | ||
}); | ||
``` | ||
|
||
The following patterns are not warnings: | ||
|
||
```js | ||
it('My spec', function() {}); | ||
|
||
describe('My suite', function() { | ||
it('My spec', function() {}); | ||
}); | ||
``` |
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,16 @@ | ||
'use strict' | ||
|
||
/** | ||
* @fileoverview Disallow the use of focused tests | ||
* @author Tom Vincent | ||
*/ | ||
|
||
var prohibit = require('../helpers/prohibit') | ||
|
||
module.exports = function (context) { | ||
var prohibiteds = [ | ||
'pending' | ||
] | ||
|
||
return prohibit(prohibiteds, context) | ||
} |
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,35 @@ | ||
'use strict' | ||
|
||
var rule = require('../../lib/rules/no-pending-tests') | ||
var RuleTester = require('eslint').RuleTester | ||
|
||
var eslintTester = new RuleTester() | ||
|
||
eslintTester.run('no-pending-tests', rule, { | ||
valid: [ | ||
'describe("", function() { it("", function() {} ) })', | ||
'it("", function() {})' | ||
], | ||
|
||
invalid: [ | ||
{ | ||
// code: 'describe("My suite with pending test", function() { it("my pending test", function() { pending(); } });', | ||
code: 'describe("My suite with pending test", function() { it("my pending test", function() { pending(); }); });', | ||
errors: [ | ||
{ | ||
message: 'Unexpected pending.', | ||
type: 'CallExpression' | ||
} | ||
] | ||
}, | ||
{ | ||
code: 'it("My pending spec", function() { pending("I am pending"); });', | ||
errors: [ | ||
{ | ||
message: 'Unexpected pending.', | ||
type: 'CallExpression' | ||
} | ||
] | ||
} | ||
] | ||
}) |