toBeInstanceOf( Function ) not working as expected.
See original GitHub issueJest 22.4.3
I’ve got this test, that works:
expect( typeof bar.method ).toBe( 'function' ) // it works
but then this fails:
expect( bar.method ).toBeInstanceOf( Function )
with output:
expect(value).toBeInstanceOf(constructor)
Expected value to be an instance of:
"Function"
Received:
[Function method]
Constructor:
"Function"
270 | console.log('1')
271 | expect( typeof bar.method ).toBe( 'function' )
> 272 | expect( bar.method ).toBeInstanceOf( Function )
273 |
274 | Bar = Class({
275 | method() {}
Seems like it should not fail.
Issue Analytics
- State:
- Created 5 years ago
- Comments:9
Top Results From Across the Web
`toBeInstanceOf(Number)` does not work in jest - Stack Overflow
I have a test as follows: expect(result.data.quota).toBeInstanceOf(Number);.
Read more >Expect - Jest
The expect function is used every time you want to test a value. You will rarely call expect by itself. Instead, you will...
Read more >Expect · Jest
The expect function is used every time you want to test a value. ... A boolean to let you know this matcher was...
Read more >Expect / Should - Chai Assertion Library
.not. Negates all assertions that follow in the chain. expect(function ... By default, all of the target's properties are searched when working with...
Read more >Jest cheatsheet - Devhints
Run your tests npm test -- --watch. See: Getting started ... expect(value) .not .toBe(value) .toEqual(value) . ... expect(value) .toBeInstanceOf(Class) .
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
Closing as dupe, then. Follow that for updates (hope to have it solved for jest 23)
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.