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.

Error on latest version on Jest (23.5.0)

See original GitHub issue

Here’s a checklist you can use to make sure your issue can be more easily resolved:

  • Check against the latest
  • Include a link to the example application source code
  • Paste into this issue the exact error messages messages you’re seeing

Whenever I run my tests with Jest version 21.2.1 everything works fine, but when I install Jest version 23.5.0 I receive the following error:

Error: expect(jest.fn())[.not].toHaveBeenCalledWith()
jest.fn() value must be a mock function or spy.
Received:  function: [Function getItem]

i.e. localStorage.getItem is not being mocked out

I’m on the latest version of jest-localstorage-mock (2.2.0) and my test setup file looks as follows:

import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import 'jest-localstorage-mock';

configure({ adapter: new Adapter() });

beforeEach(() => {
    localStorage.clear();
});

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
JPStrydomcommented, Sep 4, 2018

It seems that upgrading to Jest 22.0.0 or beyond causes the issue

2reactions
AlexandrLicommented, Oct 14, 2018

Hey, guys, I guess this issue could be closed due merge of #80. Btw, I don’t see any release with this changes. Any comments on this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

jest 23.5.0 vulnerabilities - Snyk
Report a new vulnerability Found a mistake? Direct Vulnerabilities. No direct vulnerabilities have been found for this package in Snyk's vulnerability database.
Read more >
Unresolved function or method "xxx" from Jest (23.5.0) in ...
For all the Jest methods (e.g. toHaveBeenCalledWith , toHaveLength ), I receive a Unresolved function or method "xxx" error. I have @types/jest ...
Read more >
jest - npm
Latest version : 29.3.1, last published: 2 months ago. Start using jest in your project by running `npm i jest`.
Read more >
jest | Yarn - Package Manager
Important: This documentation covers modern versions of Yarn. For 1.x docs, see classic.yarnpkg.com. Yarn.
Read more >
Unit Testing - Gatsby
Unit testing is a great way to protect against errors in your code before you deploy ... Note: if you're using Jest 23.5.0...
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