-
-
Notifications
You must be signed in to change notification settings - Fork 634
Enable Jest ESLint plugin with recommended config #1728
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
Open
alexeyr-ci2
wants to merge
3
commits into
master
Choose a base branch
from
alexeyr/eslint-jest
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -37,7 +37,6 @@ describe('ComponentRegistry', () => { | |
}); | ||
|
||
it('registers and retrieves React function components', () => { | ||
expect.assertions(1); | ||
const C1 = () => <div>HELLO</div>; | ||
ComponentRegistry.register({ C1 }); | ||
const actual = ComponentRegistry.get('C1'); | ||
|
@@ -46,7 +45,6 @@ describe('ComponentRegistry', () => { | |
}); | ||
|
||
it('registers and retrieves Render-Function components where property renderFunction is set and zero params', () => { | ||
expect.assertions(1); | ||
const C1 = () => <div>HELLO</div>; | ||
C1.renderFunction = true; | ||
ComponentRegistry.register({ C1 }); | ||
|
@@ -56,7 +54,6 @@ describe('ComponentRegistry', () => { | |
}); | ||
|
||
it('registers and retrieves ES5 class components', () => { | ||
expect.assertions(1); | ||
const C2 = createReactClass({ | ||
render() { | ||
return <div> WORLD </div>; | ||
|
@@ -69,7 +66,6 @@ describe('ComponentRegistry', () => { | |
}); | ||
|
||
it('registers and retrieves ES6 class components', () => { | ||
expect.assertions(1); | ||
class C3 extends React.Component { | ||
render() { | ||
return <div>Wow!</div>; | ||
|
@@ -82,7 +78,6 @@ describe('ComponentRegistry', () => { | |
}); | ||
|
||
it('registers and retrieves renderers if 3 params', () => { | ||
expect.assertions(1); | ||
const C4 = (a1, a2, a3) => null; | ||
ComponentRegistry.register({ C4 }); | ||
const actual = ComponentRegistry.get('C4'); | ||
|
@@ -95,7 +90,6 @@ describe('ComponentRegistry', () => { | |
* Thus, tests are cumulative. | ||
*/ | ||
it('registers and retrieves multiple components', () => { | ||
expect.assertions(4); | ||
// Plain react stateless functional components | ||
const C5 = () => <div>WHY</div>; | ||
const C6 = () => <div>NOW</div>; | ||
|
@@ -127,7 +121,6 @@ describe('ComponentRegistry', () => { | |
}); | ||
|
||
it('only detects a renderer function if it has three arguments', () => { | ||
expect.assertions(2); | ||
const C7 = (a1, a2) => null; | ||
const C8 = (a1) => null; | ||
ComponentRegistry.register({ C7 }); | ||
|
@@ -148,20 +141,17 @@ describe('ComponentRegistry', () => { | |
}); | ||
|
||
it('throws error for retrieving unregistered component', () => { | ||
expect.assertions(1); | ||
expect(() => ComponentRegistry.get('foobar')).toThrow( | ||
/Could not find component registered with name foobar/, | ||
); | ||
}); | ||
|
||
it('throws error for setting null component', () => { | ||
expect.assertions(1); | ||
const C9 = null; | ||
expect(() => ComponentRegistry.register({ C9 })).toThrow(/Called register with null component named C9/); | ||
}); | ||
|
||
it('retrieves component asynchronously when registered later', async () => { | ||
expect.assertions(1); | ||
const C1 = () => <div>HELLO</div>; | ||
const componentPromise = ComponentRegistry.getOrWaitForComponent('C1'); | ||
ComponentRegistry.register({ C1 }); | ||
|
@@ -175,11 +165,12 @@ describe('ComponentRegistry', () => { | |
}); | ||
|
||
it('handles timeout for unregistered components', async () => { | ||
expect.assertions(1); | ||
let error; | ||
try { | ||
await ComponentRegistry.getOrWaitForComponent('NonExistent'); | ||
} catch (error) { | ||
expect(error.message).toMatch(/Could not find component/); | ||
} catch (e) { | ||
error = e; | ||
} | ||
expect(error.message).toMatch(/Could not find component/); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoids conditional |
||
}); | ||
}); |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eslint-plugin-jest
bans theseexpect.assertions(...)
calls outside actual tests.The ones in them are allowed but not actually useful, they are good in two cases:
async
/await
;expect
including intry
/catch
, also banned by the plugin.