Files
medusa-store/www/apps/resources/app/test-tools-reference/moduleIntegrationTestRunner/page.mdx
Shahed Nasser 24199fa47a docs: general updates and fixes (#13374)
* docs: general updates and fixes

* fix lint errors
2025-09-02 09:07:07 +03:00

164 lines
4.6 KiB
Plaintext

import { TypeList } from "docs-ui"
export const metadata = {
title: `moduleIntegrationTestRunner Reference`,
}
# {metadata.title}
This is a reference to the `moduleIntegrationTestRunner` function provided by the `@medusajs/test-utils` package.
## Example
```ts
import { moduleIntegrationTestRunner } from "@medusajs/test-utils"
import { BLOG_MODULE } from ".."
import BlogModuleService from "../service"
import Post from "../models/post"
moduleIntegrationTestRunner<BlogModuleService>({
moduleName: BLOG_MODULE,
moduleModels: [Post],
resolve: "./src/modules/blog",
testSuite: ({ service }) => {
// TODO write tests
},
})
```
## Parameters
<TypeList
types={[
{
type: "`object`",
name: "Input",
description: "Object parameter of test options.",
children: [
{
type: "`string`",
name: "moduleName",
description: "The module's name.",
},
{
type: "string",
name: "resolve",
description: "The path to the module relative to the `src` directory.",
},
{
type: "`() => void`",
name: "testSuite",
description: "The Jest tests to run.",
},
{
type: "DmlEntity[]",
name: "moduleModels",
description: "The module's data models.",
optional: true
},
{
type: "`Record<string, any>`",
name: "moduleOptions",
description: "Options to pass to the module.",
optional: true
},
{
type: "`Record<string, any>`",
name: "injectedDependencies",
description: "Dependencies to inject into the module's container. The key is the registration name, and the value is the instance of the dependency.",
optional: true
},
{
type: "`string`",
name: "schema",
description: "The PostgreSQL schema that the database is created in.",
optional: true
},
{
type: "`boolean`",
name: "debug",
description: "Whether to show database log messages.",
defaultValue: "false",
optional: true
},
{
type: "`string`",
name: "cwd",
description: "The current working directory. If not set, the directory that you run the test command from is considered the current working directory.",
optional: true
}
]
}
]}
sectionTitle="Parameters"
openedLevel={2}
/>
## Test Suite Parameters
The function passed to `testSuite` accepts the following parameters:
<TypeList
types={[
{
type: "`object`",
name: "Input",
description: "Object parameter of test utilities.",
children: [
{
type: "any",
name: "service",
description: "An instance of the module's main service. Its type is the type argument passed to the `moduleIntegrationTestRunner` function.",
optional: false
},
{
type: "`Record<string, string>`",
name: "dbConfig",
description: "The created database's configurations",
children: [
{
type: "`string`",
name: "schema",
description: "The PostgreSQL schema the database is created in."
},
{
type: "`string`",
name: "clientUrl",
description: "The connection URL to the database."
},
]
},
{
type: "`TestDatabase`",
name: "MikroOrmWrapper",
description: "Utility functions to query and manage the database.",
children: [
{
type: `[SqlEntityManager](https://mikro-orm.io/api/knex/class/EntityManager)`,
name: "manager",
description: "An instance of MikroORM's entity manager, which can be used to run queries and perform other database tasks."
},
{
type: "`() => Promise<void>`",
name: "setupDatabase",
description: "Creates the database for the test."
},
{
type: "`() => Promise<void>`",
name: "clearDatabase",
description: "Removes all data in the database's tables."
},
{
type: "`() => SqlEntityManager`",
name: "forkManager",
description: "Returns a new entity manager."
}
]
}
]
}
]}
sectionTitle="Test Suite Parameters"
openedLevel={2}
/>