Skip to content
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

require.requireActual returning mock of lodash in jest@0.8.2 #670

Closed
sterpe opened this issue Jan 14, 2016 · 7 comments
Closed

require.requireActual returning mock of lodash in jest@0.8.2 #670

sterpe opened this issue Jan 14, 2016 · 7 comments

Comments

@sterpe
Copy link

sterpe commented Jan 14, 2016

This seems weird but I am seeing require.requireActual returning mocks instead of the actual

node 4.2.4
npm@2
jest 0.8.2

// testsetup.js
jasmine.VERBOSE = true

//__tests__/test.js
const _ = require.requireActual('lodash')
console.log(_)

// Console output
Clearly shows this is a mocked object where all functions return `undefined`

// Expected
This should return the actual 'lodash' exportable.

The work around is to add
"<rootDir>/node_modules/lodash" to unmockedModulePathPatterns...but it doesn't feel like that should be necessary...?

@sterpe
Copy link
Author

sterpe commented Jan 14, 2016

It's also possible that I'm not understanding what require.requireActual is suppose to provide.??

@cpojer
Copy link
Member

cpojer commented Jan 15, 2016

This is almost certainly a bug. Can you publish a test repository with a repro for me so I can fix this?

@sterpe
Copy link
Author

sterpe commented Jan 15, 2016

@sterpe
Copy link
Author

sterpe commented Jan 17, 2016

@cpojer Update, this may be related to #231, taking the demo repo above sterpe/jest--670, and swapping out lodash for underscore fixes the problem. So seems like require.requireActual doesn't work specifically for lodash without adding the library specifically to unmockedModulePathPatterns? Hope that helps.

@sterpe
Copy link
Author

sterpe commented Jan 17, 2016

Updated the repro here to include a test with lodash and a test with underscore:
sterpe/jest--670

@sterpe sterpe changed the title require.requireActual returning mocks in jest@0.8.2 require.requireActual returning mock of lodash in jest@0.8.2 Jan 17, 2016
@cpojer
Copy link
Member

cpojer commented Mar 3, 2016

Sorry for not getting back to you earlier but this issue should be resolved in jest 0.9.0. I think you might have been using npm3 or deduped some npm2 dependencies because your repro passes just fine for me. See #554 #732 #737

Let me know if this is not fixed when using jest-cli@next and I will reopen and investigate again.

@cpojer cpojer closed this as completed Mar 3, 2016
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants