`prefer-spy-on` should ignore `jest.fn` outside of `test` blocks
See original GitHub issuePer this, the new rule should not recommend replacing jest.fn
with jest.spyOn
when used outside of test
blocks, since jest.spyOn
can’t even be used outside of test blocks.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
The Jest Object
The jest object is automatically in scope within every test file. The methods in the jest object help create mocks and let you...
Read more >Mock Functions or Spies Demystified - How Does jest.fn() Work?
In this guide, we will focus on the jest.fn method, the simplest way to create a mock function. This method can receive an...
Read more >eslint-plugin-jest - npm
Start using eslint-plugin-jest in your project by running `npm i ... Disallow using expect outside of it or test blocks, ✓.
Read more >How to limit the scope of Jest mocked functions to a single test
This is how I structure my tests: Having a beforeAll block in the beginning of the test suit for. setting up the mocks;...
Read more >How to automatically reset mocks and restore spies in Jest
As it seemed, it turned out Jest can be configured to do an automatic reset / restore before executing each unit test spec....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yeah I decided to use
files: ['**/__mocks__/*.js'],
.You can use multiple patterns yes, but you should also be able to cover it w/ a single glob pattern, which I thought mine should do…
You might need
**
instead of*
- my globbing isn’t super strong; it otherwise could just be b/c of the paths being used you have to account for/*/__mocks__/
somehow (if that makes sense).Eitherway, using multiple patterns will definitely cover it 😃