-
Notifications
You must be signed in to change notification settings - Fork 5
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
Issues with Create-React-App #1
Comments
As a non-CRA, non-Jest user can you help me understand a bit why Jest is different under CRA than independently? |
Hi @HoltMansfield, could you post your test helper file where you are including |
@davemo my pleasure /* eslint import/no-extraneous-dependencies: "off" */ import mockLocalStorage from '../test/mockLocalStorage' // setup enzyme to work with React 16 // setup enzyme as teh default serializer // mock local localStorage global.td = require('testdouble') |
requireActual is not actually inside the jest package |
Looks to me like you haven't imported |
It's definitely not undefined. When I console.log it I get the output from my original post. Let me try again to explicitly import jest. I did that earlier today but it was in the middle of trying a million things. |
`/* eslint import/no-extraneous-dependencies: "off" */ // setup enzyme to work with React 16 // setup enzyme as teh default serializer global.td = require('testdouble') Results in a different error:
I'm extremely appreciative of your time gentlemen. I sincerely hope I'm not just doing something stupid. :) |
requireActual isn't in any of the jest packages...seems to get tacked on by require? |
git-grep pointed me to the fact |
(I haven't looked into this further yet) |
@searls I'm sorry I didn't point out earlier that CRA is behind on jest. They're on 20.0.4 I installed the latest jest and everything blows up so it seems it doesn't work with CRA. This may be yet another reason to make my own webpack config. |
The people who maintain CRA should talk to the people who maintain Jest! |
@davemo the reason I'm suddenly seeing an entire weekend spent on this flash before my eyes. |
@davemo please hit me up if I can help. I love using testdouble. I'm available all weekend. |
According to this response, CRA should be out in a few weeks and (at least somebody) expects it to remedy this situation https://twitter.com/lgandecki/status/969877478335500288
|
I tested it and yes, test-double seems to work on the CRA@next branch. However the CRA@next branch is rather unstable and is currently broken due to something related to Babel. |
Awesome! Thanks @AnaRobynn |
TypeError: jest.requireActual is not a function
at td.mock (node_modules/testdouble-jest/index.js:13:28)
The instance of jest that gets passed to testdouble has the following signature:
{
addMatchers: [Function: addMatchers],
autoMockOff: [Function: disableAutomock],
autoMockOn: [Function: enableAutomock],
clearAllMocks: [Function: clearAllMocks],
clearAllTimers: [Function: clearAllTimers],
deepUnmock: [Function: deepUnmock],
disableAutomock: [Function: disableAutomock],
doMock: [Function: mock],
dontMock: [Function: unmock],
enableAutomock: [Function: enableAutomock],
fn: [Function: bound fn],
genMockFn: [Function: bound fn],
genMockFromModule: [Function: genMockFromModule],
genMockFunction: [Function: bound fn],
isMockFunction: [Function: isMockFunction],
mock: [Function: mock],
resetAllMocks: [Function: resetAllMocks],
resetModuleRegistry: [Function: resetModules],
resetModules: [Function: resetModules],
runAllImmediates: [Function: runAllImmediates],
runAllTicks: [Function: runAllTicks],
runAllTimers: [Function: runAllTimers],
runOnlyPendingTimers: [Function: runOnlyPendingTimers],
runTimersToTime: [Function: runTimersToTime],
setMock: [Function: setMock],
spyOn: [Function: bound spyOn],
unmock: [Function: unmock],
useFakeTimers: [Function: useFakeTimers],
useRealTimers: [Function: useRealTimers]
}
Steps to reproduce:
Create a react app with create-react-app
Install testdouble-jest and configure as described in the docs.
Try to use replace as:
let bar, subject
describe('td.replace', () => {
beforeEach(() => {
bar = td.replace('./bar')
subject = require('./foo')
})
I'd be interested in helping out with this but it almost seems like there would need to be a whole separate library for this. Something like testdouble-jest-for-cra
The text was updated successfully, but these errors were encountered: