medusajs / medusa

The world's most flexible commerce platform.
https://medusajs.com
MIT License
25.95k stars 2.61k forks source link

Fail to run integration tests #9904

Closed kingwill101 closed 1 week ago

kingwill101 commented 2 weeks ago

Bug report

Not able to run integration tests

Describe the bug

The following error occurs when attempting to run an integration test in a new medusa project


      at node_modules/@medusajs/test-utils/src/medusa-test-runner-utils/use-db.ts:46:15
          at Array.forEach (<anonymous>)

{"level":"warn","message":"Local Event Bus installed. This is not recommended for production.","timestamp":"2024-11-03 03:52:48"}
{"level":"warn","message":"No default locking provider explicit defined. Using \"in-memory\" as default.","timestamp":"2024-11-03 03:52:48"}
  console.log
    redisUrl not found. A fake redis instance will be used.

      at ConfigManager.normalizeProjectConfig (node_modules/@medusajs/framework/src/config/config.ts:124:15)

{"level":"info","message":"No job to load from /home/kingwill101/code/capcom-proj/ap/my-medusa-store/node_modules/@medusajs/medusa/dist/jobs. skipped.","timestamp":"2024-11-03 03:52:50"}
  console.error
    Error starting the app Could not find index.html in the admin build directory. Make sure to run 'medusa build' before starting the server.

      at Object.beforeAll_ (node_modules/@medusajs/test-utils/src/medusa-test-runner.ts:150:15)

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

  ●  › Ping › ping the server health endpoint

    Could not find index.html in the admin build directory. Make sure to run 'medusa build' before starting the server.

      at serve (node_modules/@medusajs/admin-bundler/dist/index.js:1344:11)
      at serveProductionBuild (node_modules/@medusajs/medusa/src/loaders/admin.ts:75:28)
      at loadEntrypoints (node_modules/@medusajs/medusa/src/loaders/index.ts:108:3)
      at Object.<anonymous>.exports.default (node_modules/@medusajs/medusa/src/loaders/index.ts:164:31)
      at bootstrapApp (node_modules/@medusajs/test-utils/src/medusa-test-runner-utils/bootstrap-app.ts:17:35)
      at startApp (node_modules/@medusajs/test-utils/src/medusa-test-runner-utils/bootstrap-app.ts:45:7)
      at Object.beforeAll_ (node_modules/@medusajs/test-utils/src/medusa-test-runner.ts:141:11)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        11.535 s
Ran all test suites.
Force exiting Jest: Have you considered using `--detectOpenHandles` to detect async operations that kept running after all tests finished?
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

System information

Medusa version (including plugins): 2.0.1 Node.js version: v20.11.1 Database: postgre Operating system: linux Browser (if relevant):

Steps to reproduce the behavior

  1. npx create-medusa-app@latest 2.yarn run test:integration:http

Expected behavior

A clear and concise description of what you expected to happen

Screenshots

If applicable, add screenshots to help explain your problem

Code snippets

If applicable, add code samples to help explain your problem

Additional context

Add any other context about the problem here

olivermrbl commented 1 week ago

@kingwill101, thanks for the report. We'll look into this.

In the meantime, you can run the test suite with the NODE_ENV=development flag, and it should work as expected.

triplecasquette commented 1 week ago

By the way I will add this :

Dev mode :

info:    Skipping instrumentation registration. No register function found.
info:    Connection to Redis in module 'cache-redis' established
info:    Connection to Redis in module 'event-bus-redis' established
info:    Connection to Redis in module 'workflow-engine-redis' established
info:    Connection to Redis PubSub in module 'workflow-engine-redis' established
warn:    No default locking provider explicit defined. Using "in-memory" as default.
info:    No job to load from /home/shannon/dpc/medusa/node_modules/.pnpm/@medusajs+medusa@2.0.1_t54ea27v67fqr5ahlkeyscflri/node_modules/@medusajs/medusa/dist/jobs. skipped.
info:    Generated modules types
✔ Server is ready on port: 9000 – 21ms

Production :

> medusa-starter-default@0.0.1 start /home/shannon/dpc/medusa
> medusa start

{"level":"info","message":"Skipping instrumentation registration. No register function found.","timestamp":"2024-11-03 19:58:58"}
{"level":"info","message":"Connection to Redis in module 'cache-redis' established","timestamp":"2024-11-03 19:58:58"}
{"level":"info","message":"Connection to Redis in module 'event-bus-redis' established","timestamp":"2024-11-03 19:58:58"}
{"level":"info","message":"Connection to Redis in module 'workflow-engine-redis' established","timestamp":"2024-11-03 19:58:59"}
{"level":"info","message":"Connection to Redis PubSub in module 'workflow-engine-redis' established","timestamp":"2024-11-03 19:58:59"}
{"level":"warn","message":"No default locking provider explicit defined. Using \"in-memory\" as default.","timestamp":"2024-11-03 19:58:59"}
{"level":"info","message":"No job to load from /home/shannon/dpc/medusa/node_modules/.pnpm/@medusajs+medusa@2.0.1_t54ea27v67fqr5ahlkeyscflri/node_modules/@medusajs/medusa/dist/jobs. skipped.","timestamp":"2024-11-03 19:59:02"}
{"level":"error","message":"Error starting server","stack":[{"columnNumber":11,"fileName":"/home/shannon/dpc/medusa/node_modules/.pnpm/@medusajs+admin-bundler@2.0.1_@babel+runtime@7.26.0_@types+node@20.17.6_@types+react-dom@18.3_ula5o4qawbyfjv65tqurclwuuq/node_modules/@medusajs/admin-bundler/dist/index.js","functionName":"serve","lineNumber":1344,"methodName":null,"native":false,"typeName":null},{"columnNumber":28,"fileName":"/home/shannon/dpc/medusa/node_modules/.pnpm/@medusajs+medusa@2.0.1_t54ea27v67fqr5ahlkeyscflri/node_modules/@medusajs/medusa/src/loaders/admin.ts","functionName":"serveProductionBuild","lineNumber":75,"methodName":null,"native":false,"typeName":null},{"columnNumber":3,"fileName":"/home/shannon/dpc/medusa/node_modules/.pnpm/@medusajs+medusa@2.0.1_t54ea27v67fqr5ahlkeyscflri/node_modules/@medusajs/medusa/src/loaders/index.ts","functionName":"async loadEntrypoints","lineNumber":108,"methodName":null,"native":false,"typeName":null},{"columnNumber":31,"fileName":"/home/shannon/dpc/medusa/node_modules/.pnpm/@medusajs+medusa@2.0.1_t54ea27v67fqr5ahlkeyscflri/node_modules/@medusajs/medusa/src/loaders/index.ts","functionName":"async exports.default","lineNumber":164,"methodName":"default","native":false,"typeName":"async exports"},{"columnNumber":50,"fileName":"/home/shannon/dpc/medusa/node_modules/.pnpm/@medusajs+medusa@2.0.1_t54ea27v67fqr5ahlkeyscflri/node_modules/@medusajs/medusa/src/commands/start.ts","functionName":"async internalStart","lineNumber":120,"methodName":null,"native":false,"typeName":null},{"columnNumber":5,"fileName":"/home/shannon/dpc/medusa/node_modules/.pnpm/@medusajs+medusa@2.0.1_t54ea27v67fqr5ahlkeyscflri/node_modules/@medusajs/medusa/src/commands/start.ts","functionName":"async start","lineNumber":221,"methodName":null,"native":false,"typeName":null}],"timestamp":"2024-11-03 19:59:02"}

How to define this Locking provider ?????

thetutlage commented 1 week ago

Fixed by https://github.com/medusajs/medusa/pull/9915

thetutlage commented 1 week ago

@triplecasquette This seems like a separate question. Can you please create a dedicated issue for it or ask it in the discussion forum? 🙏