Skip to content

[Bug]: Integration tests fail on sync-links for projects that have plugins with links #12689

@dwene

Description

@dwene

Package.json file

{
  "name": "medusa",
  "version": "0.0.1",
  "description": "A starter for Medusa projects.",
  "author": "Medusa (https://medusajs.com)",
  "license": "MIT",
  "keywords": [
    "sqlite",
    "postgres",
    "typescript",
    "ecommerce",
    "headless",
    "medusa"
  ],
  "scripts": {
    "nukedb": "docker compose down -v && docker compose up -d",
    "build": "medusa build",
    "seed": "medusa exec ./src/scripts/seed.ts",
    "start": "medusa start",
    "dev": "medusa develop",
    "sync": "medusa db:sync-links",
    "migrate:prod": "medusa db:migrate",
    "start:prod": "medusa start",
    "seed:prod": "medusa exec ./src/scripts/seed.js && yarn add-user:prod",
    "add-user:prod": "medusa user --email [email protected] --password supersecret && medusa user --email [email protected] --password password",
    "migrate": "medusa db:migrate",
    "test:integration:http": "TEST_TYPE=integration:http NODE_OPTIONS=--experimental-vm-modules jest --silent=false --runInBand --forceExit",
    "test:integration:modules": "TEST_TYPE=integration:modules NODE_OPTIONS=--experimental-vm-modules jest --silent --runInBand --forceExit",
    "test:unit": "TEST_TYPE=unit NODE_OPTIONS=--experimental-vm-modules jest --silent --runInBand --forceExit",
    "medusa:init": "yarn run nukedb && medusa db:create --db medusa2 && yarn run migrate && yarn run sync && yarn run seed && yarn run add-user",
    "add-user": "medusa user --email [email protected] --password supersecret && medusa user --email [email protected] --password password",
    "typecheck": "tsc --noEmit"
  },
  "dependencies": {
    "@lambdacurry/medusa-product-reviews": "1.2.1",
    "@medusajs/admin-sdk": "2.7.0",
    "@medusajs/cli": "2.7.0",
    "@medusajs/framework": "2.7.0",
    "@medusajs/js-sdk": "2.7.0",
    "@medusajs/medusa": "2.7.0",
    "@medusajs/types": "2.7.0",
    "@mikro-orm/core": "6.4.3",
    "@mikro-orm/knex": "6.4.3",
    "@mikro-orm/migrations": "6.4.3",
    "@mikro-orm/postgresql": "6.4.3",
    "awilix": "^8.0.1",
    "pg": "^8.13.0"
  },
  "devDependencies": {
    "@medusajs/test-utils": "2.7.0",
    "@mikro-orm/cli": "6.4.3",
    "@mikro-orm/core": "6.4.3",
    "@mikro-orm/migrations": "6.4.3",
    "@mikro-orm/postgresql": "6.4.3",
    "@stdlib/number-float64-base-normalize": "0.0.8",
    "@swc/core": "1.5.7",
    "@swc/jest": "^0.2.36",
    "@types/express": "^4.17.13",
    "@types/jest": "^29.5.12",
    "@types/mime": "1.3.5",
    "@types/node": "^17.0.8",
    "@types/react": "^18.3.2",
    "jest": "^29.7.0",
    "prop-types": "^15.8.1",
    "ts-node": "^10.9.2",
    "typescript": "^5.7.3",
    "yalc": "^1.0.0-pre.53"
  },
  "installConfig": {
    "hoistingLimits": "workspaces"
  },
  "engines": {
    "node": ">=20"
  }
}

Node.js version

22

Database and its version

Postgres 17

Operating system name and version

OSX

Browser name

No response

What happended?

If I add a plugin that has links, integration tests fail with the following error:

    Service product_review was not found. If this is your module, make sure you set isQueryable to true in medusa-config.js:
            
    product_review: {
      // ...
      definition: {
        isQueryable: true
      }
    }

      at register (node_modules/@medusajs/utils/dist/modules-sdk/define-link.js:305:19)
      at MedusaApp_ (node_modules/@medusajs/modules-sdk/src/medusa-app.ts:444:30)
      at MedusaAppGetLinksExecutionPlanner (node_modules/@medusajs/modules-sdk/src/medusa-app.ts:643:45)
      at MedusaAppLoader.getLinksExecutionPlanner (node_modules/@medusajs/framework/src/medusa-app-loader.ts:206:12)
      at syncLinks (node_modules/@medusajs/test-utils/src/medusa-test-runner-utils/use-db.ts:48:21)
      at MedusaTestRunner.setupApplication (node_modules/@medusajs/test-utils/src/medusa-test-runner.ts:154:5)
      at MedusaTestRunner.beforeAll (node_modules/@medusajs/test-utils/src/medusa-test-runner.ts:229:7)
      at Object.<anonymous> (node_modules/@medusajs/test-utils/src/medusa-test-runner.ts:318:7)

I'm able to workaround this by defining the modules manually that are defined in the plugin.

Workaround PR: lambda-curry/medusa2-starter#70

I also tested on the latest medusa version (on another project), and this still happens.

Expected behavior

Plugins (that have links defined) should work for integration tests.

Actual behavior

Integration test setup fails for projects with plugins (that have links defined)

Link to reproduction repo

https://github.com/lambda-curry/medusa2-starter

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions