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
Reacted by Alex Ilyaev, DongKeon Kim / 김동건, David Burrows, Tony Trinh, timmydoza, Peter Murphy, Charles Pritchard, Jimmy (HyounKyoung) Moon, Carlos Galarza, Sebastian "Sebbie" Silbermann and 36 more
Reacted by Christian Gill, Ives van Hoorne, David Burrows, Yeison Daza, timmydoza, Carlos Galarza, Robert Cooper, Mohit Soni, Artem Sapegin, Yan Mendes and 6 more
Reacted by the0neWhoKnocks, Yeison Daza, Tony Trinh, Fabrizio Castellarin, Jess Hines, Carlos Galarza, Mohsin, Nicola Zanon, Pawan Gangwani, Robert Cooper and 19 more
Reacted by Carlos Galarza, Pawan Gangwani, Fernando Basso and Donavon West
Would have been nicer when I called jest.mock(..) instead of getting TypeError: jest.mock is not a function, I would get a Error: not implemented yet in codesandbox.io, see: https://github.com/CompuIves/codesandbox-client/issues/513
Reacted by Sean Connolly, Yeison Daza, Jess Hines, Van der Auwermeulen Grégoire, Youcef Mammar, Jason Galea, Adrian Florescu, Yehor, Emanuel Sanabria, Sagiv ben giat and 15 more
Would have been nicer when I called jest.mock(..) instead of getting TypeError: jest.mock is not a function, I would get a Error: not implemented yet in codesandbox.io, see: https://github.com/CompuIves/codesandbox-client/issues/513
+1 As local code works fine, the "not a function" error is a bit misleading (to me anyways), as I literally found out about CodeSandbox today (super awesome BTW!) and trying to use it to testdrive react components and jest tests. Not knowing the architecture, I just assumed that if Jest was in the dependencies correctly, I could call any of the jest.x() functions.
jest.useRealTimers is not a function
TypeError: jest.useRealTimers is not a function
at runWithJestRealTimers (https://vj929.csb.app/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js:651:8)
at runWithRealTimers (https://vj929.csb.app/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js:634:12)
at Window.evaluate (https://vj929.csb.app/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js:682:26)
at z (https://codesandbox.io/static/js/sandbox.3fb0c3bb6.js:1:99284)
at G.evaluate (https://codesandbox.io/static/js/sandbox.3fb0c3bb6.js:1:111641)
at be.evaluateTranspiledModule (https://codesandbox.io/static/js/sandbox.3fb0c3bb6.js:1:121458)
at c (https://codesandbox.io/static/js/sandbox.3fb0c3bb6.js:1:111387)
at Window.evaluate (https://vj929.csb.app/node_modules/@testing-library/react/dist/@testing-library/react.esm.js:44:17)
at z (https://codesandbox.io/static/js/sandbox.3fb0c3bb6.js:1:99284)
at G.evaluate (https://codesandbox.io/static/js/sandbox.3fb0c3bb6.js:1:111641)
at be.evaluateTranspiledModule (https://codesandbox.io/static/js/sandbox.3fb0c3bb6.js:1:121458)
at c (https://codesandbox.io/static/js/sandbox.3fb0c3bb6.js:1:111387)
at Window.evaluate (https://vj929.csb.app/src/__tests__/react-lazy-and-suspense.js:13:15)
at z (https://codesandbox.io/static/js/sandbox.3fb0c3bb6.js:1:99284)
at G.evaluate (https://codesandbox.io/static/js/sandbox.3fb0c3bb6.js:1:111641)
at be.evaluateTranspiledModule (https://codesandbox.io/static/js/sandbox.3fb0c3bb6.js:1:121458)
at be.evaluateModule (https://codesandbox.io/static/js/sandbox.3fb0c3bb6.js:1:120957)
at https://codesandbox.io/static/js/7.4b9a6a838.chunk.js:1:15776
at l (https://codesandbox.io/static/js/common-sandbox.51de09afd.chunk.js:1:257422)
at Generator._invoke (https://codesandbox.io/static/js/common-sandbox.51de09afd.chunk.js:1:257175)
at Generator.forEach.e.<computed> [as next] (https://codesandbox.io/static/js/common-sandbox.51de09afd.chunk.js:1:257779)
at t (https://codesandbox.io/static/js/common-sandbox.51de09afd.chunk.js:1:2420)
at i (https://codesandbox.io/static/js/common-sandbox.51de09afd.chunk.js:1:2631)
at https://codesandbox.io/static/js/common-sandbox.51de09afd.chunk.js:1:2690
at new Promise (<anonymous>)
at https://codesandbox.io/static/js/common-sandbox.51de09afd.chunk.js:1:2571
at https://codesandbox.io/static/js/7.4b9a6a838.chunk.js:1:16135
at Array.map (<anonymous>)
at e.<anonymous> (https://codesandbox.io/static/js/7.4b9a6a838.chunk.js:1:15477)
at l (https://codesandbox.io/static/js/common-sandbox.51de09afd.chunk.js:1:257422)
at Generator._invoke (https://codesandbox.io/static/js/common-sandbox.51de09afd.chunk.js:1:257175)
at Generator.forEach.e.<computed> [as next] (https://codesandbox.io/static/js/common-sandbox.51de09afd.chunk.js:1:257779)
at t (https://codesandbox.io/static/js/common-sandbox.51de09afd.chunk.js:1:2420)
at i (https://codesandbox.io/static/js/common-sandbox.51de09afd.chunk.js:1:2631)
Reacted by Gideon Shils, Chris Moore, Peter Marcoen, Apostolis A., Davide Crestini and Orry Baram
jest.useRealTimers is not a function
TypeError: jest.useRealTimers is not a function
at runWithJestRealTimers (https://vj929.csb.app/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js:651:8)
at runWithRealTimers (https://vj929.csb.app/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js:634:12)
at Window.evaluate (https://vj929.csb.app/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js:682:26)
at z (https://codesandbox.io/static/js/sandbox.3fb0c3bb6.js:1:99284)
at G.evaluate (https://codesandbox.io/static/js/sandbox.3fb0c3bb6.js:1:111641)
at be.evaluateTranspiledModule (https://codesandbox.io/static/js/sandbox.3fb0c3bb6.js:1:121458)
at c (https://codesandbox.io/static/js/sandbox.3fb0c3bb6.js:1:111387)
at Window.evaluate (https://vj929.csb.app/node_modules/@testing-library/react/dist/@testing-library/react.esm.js:44:17)
at z (https://codesandbox.io/static/js/sandbox.3fb0c3bb6.js:1:99284)
at G.evaluate (https://codesandbox.io/static/js/sandbox.3fb0c3bb6.js:1:111641)
at be.evaluateTranspiledModule (https://codesandbox.io/static/js/sandbox.3fb0c3bb6.js:1:121458)
at c (https://codesandbox.io/static/js/sandbox.3fb0c3bb6.js:1:111387)
at Window.evaluate (https://vj929.csb.app/src/__tests__/react-lazy-and-suspense.js:13:15)
at z (https://codesandbox.io/static/js/sandbox.3fb0c3bb6.js:1:99284)
at G.evaluate (https://codesandbox.io/static/js/sandbox.3fb0c3bb6.js:1:111641)
at be.evaluateTranspiledModule (https://codesandbox.io/static/js/sandbox.3fb0c3bb6.js:1:121458)
at be.evaluateModule (https://codesandbox.io/static/js/sandbox.3fb0c3bb6.js:1:120957)
at https://codesandbox.io/static/js/7.4b9a6a838.chunk.js:1:15776
at l (https://codesandbox.io/static/js/common-sandbox.51de09afd.chunk.js:1:257422)
at Generator._invoke (https://codesandbox.io/static/js/common-sandbox.51de09afd.chunk.js:1:257175)
at Generator.forEach.e.<computed> [as next] (https://codesandbox.io/static/js/common-sandbox.51de09afd.chunk.js:1:257779)
at t (https://codesandbox.io/static/js/common-sandbox.51de09afd.chunk.js:1:2420)
at i (https://codesandbox.io/static/js/common-sandbox.51de09afd.chunk.js:1:2631)
at https://codesandbox.io/static/js/common-sandbox.51de09afd.chunk.js:1:2690
at new Promise (<anonymous>)
at https://codesandbox.io/static/js/common-sandbox.51de09afd.chunk.js:1:2571
at https://codesandbox.io/static/js/7.4b9a6a838.chunk.js:1:16135
at Array.map (<anonymous>)
at e.<anonymous> (https://codesandbox.io/static/js/7.4b9a6a838.chunk.js:1:15477)
at l (https://codesandbox.io/static/js/common-sandbox.51de09afd.chunk.js:1:257422)
at Generator._invoke (https://codesandbox.io/static/js/common-sandbox.51de09afd.chunk.js:1:257175)
at Generator.forEach.e.<computed> [as next] (https://codesandbox.io/static/js/common-sandbox.51de09afd.chunk.js:1:257779)
at t (https://codesandbox.io/static/js/common-sandbox.51de09afd.chunk.js:1:2420)
at i (https://codesandbox.io/static/js/common-sandbox.51de09afd.chunk.js:1:2631)
Facing the same issue too
Reacted by Chris Moore, Peter Marcoen, Guillaume RENARD, Apostolis A., Davide Crestini and Orry Baram
Yes, this is still something we want to do, but it's challenging. It's something that we haven't planned in the near-future, but we do want to expand the Jest functionality in the future. I can't tell when we'll have this though.
This issue has automatically been marked stale because there has been no activity in a while. Please leave a comment if the issue has not been resolved, or if it is not stale for any other reason. After 2 weeks, this issue will automatically be closed, unless a comment is made or the stale label is removed.
I'm looking into this one and I have some questions about the jest implementation.
Normally, when the Jest global is initialized its created by the jest-runtime and mock/other timer functions are added to the global Jest object. This can be seen here.
What's happening in codesandbox is that the jest-runtime is never being initialized - I presume there may be some reason for this. That can be seen here, where jest is actually initialized here with the MockModule class from jest-mock, which populates part of the jest globals into the global space but doesn't add functions like _createJestObjectFor() from jest-runtime. This is why you can use spyOn but not mock - jest-mock actually doesn't declare a mock function until you initialize it with the MockModule.generateFromMetadata<T, Y extends Array>(
@CompuIves you're getting tagged just because you seem to be the only maintainer here. There may be someone better who can answer these questions. Sorry about that!
Is there a reason that jest-runtime isn't being used to its full extent here?
Why is jest-mock being used as the jest object here?
I am trying to get a jest-runtime instance set up in the codesandbox world. I presume there might be issues with this - namely the jest-runtime needs some sort of file/module resolver, which may not play nicely with the codesandbox environment.
For everyone who hasn't looked into it - Jest has a lot going on and even I don't completely understand how the Jest runtime works (and its created differently for node/jsdom!).
Activity
gautamarora commentedon Feb 8, 2018
also cc @gillchristian - interested to help with code or ideas? :)
gillchristian commentedon Feb 8, 2018
Yeah, I just joined Discord, we can talk there 😄
alexilyaev commentedon Mar 7, 2018
jest.config.jssupport would be really nice.gillchristian commentedon Mar 7, 2018
@alexilyaev indeed, in the Discord I mentioned I'd like to work on it but haven't found the time yet 😬
rdiazv commentedon May 14, 2018
Fake timers 🙏
jest.useFakeTimers is not a functionthe0neWhoKnocks commentedon May 18, 2018
Just came across this ticket after commenting on another ticket #692 (comment). There may be issues utilizing
enzymeas well.To clarify, people will have issues running enzyme if they utilize setupTestFrameworkScriptFile like is suggested in the official enzyme docs https://github.com/airbnb/enzyme/blob/master/docs/guides/jest.md#configure-with-jest
Pyrolistical commentedon Jun 14, 2018
Would have been nicer when I called
jest.mock(..)instead of gettingTypeError: jest.mock is not a function, I would get aError: not implemented yet in codesandbox.io, see: https://github.com/CompuIves/codesandbox-client/issues/513codialsoftware commentedon Jul 26, 2018
or
jest.doMock;)I've look through half of half of the Internet to finally find this bug :D
jdhines commentedon Sep 19, 2018
+1 As local code works fine, the "not a function" error is a bit misleading (to me anyways), as I literally found out about CodeSandbox today (super awesome BTW!) and trying to use it to testdrive react components and jest tests. Not knowing the architecture, I just assumed that if Jest was in the dependencies correctly, I could call any of the jest.x() functions.
iDVB commentedon Jan 17, 2019
So I've read this thread over 3x and still not sure if this is still an known issue or not.
I continue to get the error...
jest.mock is not a functionThere seems to be codesandbox docs about using Jest... but no mention of limitations.
https://codesandbox.io/docs/tests
dwiyatci commentedon Feb 14, 2019
@iDVB I don't think
jest.mock()/"automatic mock" is supported yet. 🤔How do we check the version of CodeSandbox from the dashboard btw?
SaraVieira commentedon Feb 20, 2019
@dwiyatci You can check the version in any sandbox here:
dwiyatci commentedon Feb 20, 2019
@SaraVieira Thank you. :) But what I meant was: how can we tell whether it's CodeSandbox 2.5 or 3.0? 😅
SaraVieira commentedon Feb 21, 2019
Shhhhhit, no idea haha
Ask Ives 🤔
@CompuIves
mohsinulhaq commentedon Mar 8, 2019
jest.useFakeTimers is not a functionHi, is there any update for above fix?
19 remaining items
agallio commentedon Apr 1, 2021
Still got this error when running tests.
https://codesandbox.io/s/github/kentcdodds/react-testing-library-examples/tree/main/?from-embed&initialpath=%2F__tests__%2Fasync.js
dhatGuy commentedon Apr 4, 2021
Facing the same issue too
KrustyC commentedon Apr 30, 2021
Hi here, I get the same issue as well https://codesandbox.io/s/modern-morning-md378
Do we have any update on this?
wwwmonkey commentedon May 1, 2021
Apologies if cross-posting issue, but appreciate any work-around or ideas for my issue regarding Jest not working on Static templates:
#5726
CompuIves commentedon May 7, 2021
Yes, this is still something we want to do, but it's challenging. It's something that we haven't planned in the near-future, but we do want to expand the Jest functionality in the future. I can't tell when we'll have this though.
github-actions commentedon Aug 6, 2021
This issue has automatically been marked stale because there has been no activity in a while. Please leave a comment if the issue has not been resolved, or if it is not stale for any other reason. After 2 weeks, this issue will automatically be closed, unless a comment is made or the stale label is removed.
nickserv commentedon Aug 6, 2021
It seems like this is still being worked on.
robertjcolley commentedon Nov 26, 2021
I'm looking into this one and I have some questions about the jest implementation.
Normally, when the Jest global is initialized its created by the jest-runtime and mock/other timer functions are added to the global Jest object. This can be seen here.
What's happening in codesandbox is that the jest-runtime is never being initialized - I presume there may be some reason for this. That can be seen here, where jest is actually initialized here with the MockModule class from jest-mock, which populates part of the jest globals into the global space but doesn't add functions like _createJestObjectFor() from jest-runtime. This is why you can use spyOn but not mock - jest-mock actually doesn't declare a mock function until you initialize it with the MockModule.generateFromMetadata<T, Y extends Array>(
@CompuIves you're getting tagged just because you seem to be the only maintainer here. There may be someone better who can answer these questions. Sorry about that!
I am trying to get a jest-runtime instance set up in the codesandbox world. I presume there might be issues with this - namely the jest-runtime needs some sort of file/module resolver, which may not play nicely with the codesandbox environment.
For everyone who hasn't looked into it - Jest has a lot going on and even I don't completely understand how the Jest runtime works (and its created differently for node/jsdom!).
milichev commentedon Aug 26, 2022
You know what... It's really annoying to spend time writing stuff cover, it with tests, and in the end, get this one 🤦🏽♂️🙃
xblue-light commentedon Dec 18, 2022
Hey guess what .. jest.mock is still NOT a function sigh
sunny15100 commentedon Feb 13, 2023
Hey guess what .. jest.mock is still NOT a function sigh
nickserv commentedon Feb 14, 2023
I'd recommend switching to cloud sandboxes as they can natively run Node tools (including Jest).
benadam11 commentedon Mar 31, 2023
I know cloud sandboxes are recommended, but sinon.useFakeTimers works (just in case anyone was still looking for a solution)