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

Version 2.6.3 changed the way to mock libraries #293

Closed
Jeff-Tham opened this issue Feb 23, 2024 · 7 comments · Fixed by iambumblehead/resolvewithplus#67 or #295
Closed

Version 2.6.3 changed the way to mock libraries #293

Jeff-Tham opened this issue Feb 23, 2024 · 7 comments · Fixed by iambumblehead/resolvewithplus#67 or #295

Comments

@Jeff-Tham
Copy link

Prior to version 2.6.3, the follow code snippet is working fine.

    esmock(
        '../../../src/processMessages.js',
        {
          'app-utils/src/logger/logger': {
            logger: loggerStub,
          }
        }
      )

after upgrade version to 2.6.3, it produces follow error:
Error: ENOENT: no such file or directory, realpath '/xxx/node_modules/app-utils/.js.js/src/logger/logger/*' unknown .js.js included.

it expected to rewrite the code and pointed to the node_modules directory as:

    esmock(
        '../../../src/processMessages.js',
        {
          '../../../node_modules/app-utils/src/logger/logger': {
            logger: loggerStub,
          }
        }
      )

FYI, the package.json for app-utils use this setting:

  "files": [
    "src",
    "dist"
  ],
  "exports": {
    "./*": {
      "require": "./*.js",
      "import": "./*.js"
    }
  },
@iambumblehead
Copy link
Owner

night time here now but will take a look tomorrow

@iambumblehead
Copy link
Owner

@Jeff-Tham a solution should be ready in a few hours. This type of wildcard/glob expansion and matching is a "weak" area of esmock which will be improved as a result of this issue. A hacky sort-of solution was implemented a few weeks back #289 and the newer solution will be a little less hacky (imo)

@iambumblehead
Copy link
Owner

this should resolve the issue iambumblehead/resolvewithplus#67

@iambumblehead
Copy link
Owner

@Jeff-Tham thanks for opening the issue. Awaiting replies to the PR....

@Jeff-Tham
Copy link
Author

@iambumblehead , if you can publish a beta version, i can test it with my code. Thanks for the quick response!

@iambumblehead
Copy link
Owner

[email protected] is published please reopen or open a new issue if there are any problems :)

@Jeff-Tham
Copy link
Author

The bug is fixed.
Thanks @iambumblehead for the great work. I really appreciate it.

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