question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

toBeInstanceOf( Function ) not working as expected.

See original GitHub issue

Jest 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:closed
  • Created 5 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
SimenBcommented, Apr 11, 2018

Closing as dupe, then. Follow that for updates (hope to have it solved for jest 23)

0reactions
github-actions[bot]commented, May 12, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found