forked from jestjs/jest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:facebook/jest
- Loading branch information
Showing
31 changed files
with
816 additions
and
167 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
2 changes: 2 additions & 0 deletions
2
integration_tests/compare-dom-nodes/__tests__/failed-assertion.js
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
/* global document */ | ||
|
||
test('a failed assertion comparing a DOM node does not crash Jest', () => { | ||
expect(document.body).toBe(null); | ||
}); |
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
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
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 @@ | ||
**/__mocks__/** | ||
**/__tests__/** | ||
src |
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,56 @@ | ||
# eslint-plugin-jest | ||
|
||
Eslint plugin for Jest | ||
|
||
## Installation | ||
|
||
``` | ||
$ yarn add --dev eslint eslint-plugin-jest | ||
``` | ||
|
||
**Note:** If you installed ESLint globally then you must also install `eslint-plugin-jest` globally. | ||
|
||
## Usage | ||
|
||
Add `jest` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix: | ||
|
||
```json | ||
{ | ||
"plugins": [ | ||
"jest" | ||
] | ||
} | ||
``` | ||
|
||
|
||
Then configure the rules you want to use under the rules section. | ||
|
||
```json | ||
{ | ||
"rules": { | ||
"jest/no-focused-tests": "error", | ||
"jest/no-identical-title": "error" | ||
} | ||
} | ||
``` | ||
|
||
You can also whitelist the environment variables provided by Jest by doing: | ||
|
||
```json | ||
{ | ||
"env": { | ||
"jest/globals": true | ||
} | ||
} | ||
``` | ||
|
||
## Supported Rules | ||
|
||
- [no-focused-tests](docs/rules/no-focused-tests.md) - disallow focused tests. | ||
- [no-identical-title](docs/rules/no-identical-title.md) - disallow identical titles. | ||
|
||
|
||
## Credit | ||
|
||
* [eslint-plugin-mocha](https://github.com/lo1tuma/eslint-plugin-mocha) | ||
* [eslint-plugin-jasmine](https://github.com/tlvince/eslint-plugin-jasmine) |
42 changes: 42 additions & 0 deletions
42
packages/eslint-plugin-jest/docs/rules/no-focused-tests.md
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,42 @@ | ||
# Disallow Focused Tests (no-focused-tests) | ||
|
||
Jest has a feature that allows you to focus tests by appending `.only` or prepending `f` to a test-suite or a test-case. | ||
This feature is really helpful to debug a failing test, so you don’t have to execute all of your tests. | ||
After you have fixed your test and before committing the changes you have to remove `.only` to ensure all tests are executed on your build system. | ||
|
||
This rule reminds you to remove `.only` from your tests by raising a warning whenever you are using the exclusivity feature. | ||
|
||
## Rule Details | ||
|
||
This rule looks for every `describe.only`, `it.only`, `test.only`, `fdescribe`, `fit` and `ftest` occurrences within the source code. | ||
Of course there are some edge-cases which can’t be detected by this rule e.g.: | ||
|
||
```js | ||
var describeOnly = describe.only; | ||
describeOnly.apply(describe); | ||
``` | ||
|
||
The following patterns are considered warnings: | ||
|
||
```js | ||
describe.only("foo", function () {}); | ||
it.only("foo", function () {}); | ||
describe["only"]("bar", function () {}); | ||
it["only"]("bar", function () {}); | ||
test.only("foo", function () {}); | ||
test["only"]("bar", function () {}); | ||
fdescribe("foo", function () {}); | ||
fit("foo", function () {}); | ||
ftest("bar", function () {}); | ||
``` | ||
|
||
These patterns would not be considered warnings: | ||
|
||
```js | ||
describe("foo", function () {}); | ||
it("foo", function () {}); | ||
describe.skip("bar", function () {}); | ||
it.skip("bar", function () {}); | ||
test("foo", function () {}); | ||
test.skip("bar", function () {}); | ||
``` |
45 changes: 45 additions & 0 deletions
45
packages/eslint-plugin-jest/docs/rules/no-identical-title.md
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,45 @@ | ||
# Disallow identical titles (no-identical-title) | ||
|
||
Having identical titles for two different tests or test suites may create confusion. For example, when a test with the same title as another test in the same test suite fails, it is harder to know which one failed and thus harder to fix. | ||
|
||
## Rule Details | ||
|
||
This rule looks at the title of every test and test suites. It will report when two test suites or two test cases at the same level of a test suite have the same title. | ||
|
||
The following patterns are considered warnings: | ||
|
||
```js | ||
describe('foo', function () { | ||
it('should do bar', function() {}); | ||
it('should do bar', function() {}); // Has the same title as the previous test | ||
|
||
describe('baz', function() { | ||
// ... | ||
}); | ||
|
||
describe('baz', function() { // Has the same title as a previous test suite | ||
// ... | ||
}); | ||
}); | ||
``` | ||
|
||
These patterns would not be considered warnings: | ||
|
||
```js | ||
describe('foo', function () { | ||
it('should do foo', function() {}); | ||
it('should do bar', function() {}); | ||
|
||
// Has the same name as a parent test suite, which is fine | ||
describe('foo', function() { | ||
// Has the same name as a test in a parent test suite, which is fine | ||
it('should do foo', function() {}); | ||
it('should work', function() {}); | ||
}); | ||
|
||
describe('baz', function() { // Has the same title as a previous test suite | ||
// Has the same name as a test in a sibling test suite, which is fine | ||
it('should work', 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "eslint-plugin-jest", | ||
"version": "18.1.0", | ||
"description": "Eslint rules for Jest", | ||
"keywords": [ | ||
"eslint", | ||
"eslintplugin", | ||
"eslint-plugin" | ||
], | ||
"author": { | ||
"name": "Jonathan Kim", | ||
"email": "[email protected]", | ||
"url": "jkimbo.com" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/facebook/jest.git" | ||
}, | ||
"main": "build/index.js", | ||
"peerDependencies": { | ||
"eslint": ">=3.6" | ||
}, | ||
"license": "BSD-3-Clause" | ||
} |
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,40 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* @flow | ||
*/ | ||
|
||
'use strict'; | ||
|
||
module.exports = { | ||
environments: { | ||
globals: { | ||
globals: { | ||
afterAll: false, | ||
afterEach: false, | ||
beforeAll: false, | ||
beforeEach: false, | ||
describe: false, | ||
expect: false, | ||
fit: false, | ||
it: false, | ||
jasmine: false, | ||
jest: false, | ||
pit: false, | ||
require: false, | ||
test: false, | ||
xdescribe: false, | ||
xit: false, | ||
xtest: false, | ||
}, | ||
}, | ||
}, | ||
rules: { | ||
'no-focused-tests': require('./rules/no-focused-tests'), | ||
'no-identical-title': require('./rules/no-identical-title'), | ||
}, | ||
}; |
Oops, something went wrong.