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

Integration Tests fail to import custom modules #9435

Open
dwene opened this issue Oct 2, 2024 · 0 comments
Open

Integration Tests fail to import custom modules #9435

dwene opened this issue Oct 2, 2024 · 0 comments

Comments

@dwene
Copy link
Contributor

dwene commented Oct 2, 2024

Bug report

Describe the bug

Pre-configured integration tests from npx create-medusa do not work when registering a local module.

When I registered a local "auction" module, integration tests started failing with this error:

 FAIL  integration-tests/http/health.spec.ts
    Ping
      ✕ ping the server health endpoint (30 ms)

  ●  › Ping › ping the server health endpoint

    Cannot find module '/Users/derekwene/src/uplabs/lambda/apps/medusa2/dist/modules/auction'
    Require stack:
    - /Users/derekwene/src/uplabs/lambda/apps/medusa2/noop.js

      at resolveFileName (../../node_modules/resolve-from/index.js:29:39)
      at resolveFrom (../../node_modules/resolve-from/index.js:43:9)
      at Object.<anonymous>.module.exports (../../node_modules/resolve-from/index.js:46:47)
      at Object.<anonymous>.module.exports (../../node_modules/resolve-cwd/index.js:4:30)
      at getInternalModuleResolution (node_modules/@medusajs/modules-sdk/src/loaders/register-modules.ts:157:37)

I believe the issue is with this file:

https://github.com/medusajs/medusa/blob/develop/packages/core/utils/src/common/normalize-import-path-with-source.ts#L19

Since Jest is running these tests without ts-node it's incorrectly using dist instead of src.

System information

Medusa version (including plugins): 2 RC latest
Node.js version: 20
Database: Postgres
Operating system: OSX
Browser (if relevant):

Steps to reproduce the behavior

Run npx create-medusa-app@rc
Setup a custom module of any kind.
Try to run npm test:integration:http

Notice you get an error about failing to import module under ${CWD}/dist/${modulePath}

Expected behavior

Integration tests should pass.

Screenshots

Code snippets

https://github.com/medusajs/medusa/blob/develop/packages/core/utils/src/common/normalize-import-path-with-source.ts#L19

Additional context

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

No branches or pull requests

1 participant