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

Does testdouble-jest work with TypeScript? #7

Open
rene-leanix opened this issue Jun 2, 2021 · 2 comments
Open

Does testdouble-jest work with TypeScript? #7

rene-leanix opened this issue Jun 2, 2021 · 2 comments

Comments

@rene-leanix
Copy link

For our own Angular TypeScript repo, I encountered the following error when I tried out testdouble-jest: It appears the test is being run by Jest, but the testdouble-jest module has not been initialized.... I did do the initialisation with require('testdouble-jest')(td, jest) and the mock function was added to the imported testdouble module, but it was not available in the module when required again here.

I tried to reproduce this by taking the example tests from this repo, porting them to TypeScript and updating to the latest version of Jest. See #6. Unfortunately, the error did not occur there, but at the same time all the test cases fail for other reasons. I haven't had time to investigate this any further, but am posting this here in case someone from the testdouble team would like to look at this.

@forivall
Copy link

forivall commented Dec 8, 2023

When I was looking through td-jest's documentation, and with knowledge of some parts of jest.mock's internals, td.mock will need to have special code transformer logic to hoist the mock module declarations above imports for mocking to work properly. I'm not sure if that is the case here, but it certainly is Test Double Trouble.

@searls
Copy link
Member

searls commented Dec 8, 2023

I'll be honest in that I've always avoided using Jest and only slapped this module together well enough to get it to work at initial release. There's not much code here, though, so if someone has an idea on how to fix it and an interest in helping, I'd appreciate!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants