You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
describe('SomeTest',function(){it("requires underscore (unmocked) and jQuery (mocked)",function(){jest.dontMock('underscore');var_=require('underscore'),jQuery=require('jquery');expect(_.mock).toBeUndefined();expect(jQuery.mock).toBeDefined();})});
It fails because jQuery.mock is undefined.
The issue can easily reproduced by slightly modifying the included examples/tutorial/__test__/fetchCurrentUser-test.js, dropping in a single dontMock('underscore') call:
// fetchCurrentUser-test.js, l.4-11it('calls into $.ajax with the correct params',function(){jest.dontMock('underscore');var$=require('jquery');varfetchCurrentUser=require('../fetchCurrentUser');// Call into the function we want to testfunctiondummyCallback(){}fetchCurrentUser(dummyCallback);
The test will now fail since jQuery is no longer mocked.
The root cause for this is that HasteModuleLoader._getNormalizedModuleID() seems to be returning user:: for any module in node_modules, making dontMock effectively disable auto-mocking for all npm-installed modules.
The text was updated successfully, but these errors were encountered:
Ok, I think this should be fixed by 56c4f55
(I was able to confirm that it fixes your repro-case -- feel free to re-open if you're seeing any other related issues)
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.
Consider this test:
It fails because
jQuery.mock
isundefined
.The issue can easily reproduced by slightly modifying the included
examples/tutorial/__test__/fetchCurrentUser-test.js
, dropping in a singledontMock('underscore')
call:The test will now fail since jQuery is no longer mocked.
The root cause for this is that
HasteModuleLoader._getNormalizedModuleID()
seems to be returninguser::
for any module innode_modules
, makingdontMock
effectively disable auto-mocking for all npm-installed modules.The text was updated successfully, but these errors were encountered: