Errors When Running Tests

This troubleshooting guide covers common errors you may encounter when running tests in your Medusa application and how to resolve them.

Loaders for module Workflows failed#

If you get the following error when running your tests:

Terminal
❯Loaders for module Workflows failed: Method Map.prototype.set called on incompatible receiver #<Map>

This may occur if you have multiple test files and you don't configure your Jest environment correctly. To resolve this, add the following configuration to your jest.config.js file:

jest.config.js
1module.exports = {2  // ...3  setupFiles: ["./integration-tests/setup.js"],4}

Then, create the integration-tests/setup.js file with the following content:

Note: If you're using a version prior to Medusa v2.11.0, change @medusajs/framework/mikro-orm/core to @mikro-orm/core. Learn more in the v2.11.0 codemod.
integration-tests/setup.js
1const { MetadataStorage } = require("@medusajs/framework/mikro-orm/core")2
3MetadataStorage.clear()

Refer to the Testing Tools guide for more details.

Was this page helpful?
Ask Bloom
For assistance in your development, use Claude Code Plugins or Docs MCP server in Cursor, VSCode, etc...FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break
⇧↵