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
Using testdouble esm loader with ts-node/esm loader on mocha leads to errors (Node 18.6.0) #496
Comments
Could you please also make sure |
@AlexZ-343 would love to get a reproduction repository so that I can debug it this week! It would make my life much easier. |
|
Reproduced! Working on it... |
Found the bug! Fixing... |
Hi @giltayar, what's the status on the resolution? I see a fix has been fixed, but there hasn't been a release yet? |
Hi @AlexZ-343, I'm facing this issue as well. There's a fix by the node team in nodejs/node#44109. I am going to test it using node v19.0.0-nightly20220806760ecc9c75/ that includes it. if I find anything, I'll let you know. |
I've created a playground here: testdouble-ts-node-esm-playground. Mocking |
@searls did you create a release? |
@giltayar no, I'd actually invited you to after adding you as a maintainer on the npm package, along with an updated RELEASE.md doc! Would you like to try your hand at releasing a patch bump for this? |
hey @alichry, thanks for taking a look at this! Could you clarify what you mean by this statement?
I'll try playing around with it a bit on my end as well. |
Hi @AlexZ-343 👋, whoops, sorry about that.
Based on the above, mocking https://github.com/alichry/testdouble-ts-node-esm-playground/blob/d3de64aafd29294b54f9140548a3904509b2b326/src/register.spec.ts#L7-L12
|
Try updating to quibble@0.6.14 |
Hey @searls, thank you for the release! I've set it to 0.6.14 instead of the fix's commit hash. I've noticed no changes whatsoever; what am I missing? |
Not sure, just wanted to make sure you were up to day. @giltayar? |
Hey @searls and @giltayar , I tried the latest version of quibble with my dummy repo and while I am no longer seeing the lengthy exception message, I am having some trouble getting a proper mock. When I try mocking with prototype, I get this:
If I try to do it without
It acts like there is no mock (which I confirmed with some console logging). Is there an error in how I'm setting it up? Updated dummy repo for reference: https://github.com/AlexZ-343/testdouble-issue |
@AlexZ-343 looking into it. |
@AlexZ-343 this was an interesting one. There are two problems in your test code. One which is obvious, and one which is definitely not. Let's start with the obvious: You're calling To fix this, remove OK, that's the regular one. Now for the VERY non-obvious one, which got me stumped. Let's start by how to fix. Replace Why? Because the Totally non-obvious, but this is a really interesting interplay with multiple loaders here. We're probably going to see a lot fo those in the future, and now I will probably be able to figure them out without |
@giltayar thanks for walking me through this. I tried the fixes, and I still get:
This is with Is there something else I'm missing, like the exact ordering of the import or something? I updated the repo with my attempted changes. |
Oh, I fogort: the |
should end with .ts instead of .js See: testdouble/testdouble.js#496 (comment)
Hey all, sorry for the delay. I haven't had a chance to test the fix extensively. I did try it for a unit test or two and it looks good! Personally, I'd like to do a few more test cases before closing this, but I think this should be fixed at this point. |
Description
I am trying to do esm mocking using
testdouble
with a mixed Typescript and Javascript project, mostly following this postNode 18.6.0 now allows for chaining of loads, and I previously needed
ts-node/esm
in order to recognize my Typescript files and imports.I realize that this new feature is less than a week old, but I would appreciate support with reconciling other loaders that I would need for my es6 project (or to find a way that only requires one loader). Due to project requirements, using
commonjs
on runtime is not an option.Issue
When running the following mocha command:
and any permutation thereof (removing
experimental-specifier-resolution
, changing the order of the--loader
params)I get the following exception
These 4 lines repeat indefinitely:
Environment
node v18.6.0
npm v.8.13.2
testdouble v.3.16.6
Example Repo
I don't have a repo handy, but I can try to create one and add it in the future.
Code-fenced Examples
service_one.ts
service_two.ts
test.ts :
package.json:
tsconfig.json:
The text was updated successfully, but these errors were encountered: