chore(medusa-test-utils): Add debug option to the module test runner (#6462)

**What**
Add a debug options to the test runner, for now it will only switch the db to log the query but it could evolve to do more debug.
This commit is contained in:
Adrien de Peretti authored and GitHub committed 2024-02-21 13:01:03 +00:00
1 parent 8ff838970e
commit e0750bae40
2 files changed
+5 -1

No files matched your search

@@ -13,7 +13,7 @@ import {
UpdateServiceZoneDTO, UpdateServiceZoneDTO,
} from "@medusajs/types" } from "@medusajs/types"
import { GeoZoneType } from "@medusajs/utils" import { GeoZoneType } from "@medusajs/utils"
import { SuiteOptions, moduleIntegrationTestRunner } from "medusa-test-utils" import { moduleIntegrationTestRunner, SuiteOptions } from "medusa-test-utils"
jest.setTimeout(100000) jest.setTimeout(100000)
@@ -18,6 +18,7 @@ export function moduleIntegrationTestRunner({
moduleModels, moduleModels,
joinerConfig = [], joinerConfig = [],
schema = "public", schema = "public",
debug = false,
testSuite, testSuite,
}: { }: {
moduleName: string moduleName: string
@@ -25,6 +26,7 @@ export function moduleIntegrationTestRunner({
joinerConfig?: any[] joinerConfig?: any[]
schema?: string schema?: string
dbName?: string dbName?: string
debug?: boolean
testSuite: <TService = unknown>(options: SuiteOptions<TService>) => () => void testSuite: <TService = unknown>(options: SuiteOptions<TService>) => () => void
}) { }) {
moduleModels = Object.values(require(`${process.cwd()}/src/models`)) moduleModels = Object.values(require(`${process.cwd()}/src/models`))
@@ -36,6 +38,7 @@ export function moduleIntegrationTestRunner({
const dbConfig = { const dbConfig = {
clientUrl: getDatabaseURL(dbName), clientUrl: getDatabaseURL(dbName),
schema, schema,
debug,
} }
// Use a unique connection for all the entire suite // Use a unique connection for all the entire suite
@@ -54,6 +57,7 @@ export function moduleIntegrationTestRunner({
defaultAdapterOptions: { defaultAdapterOptions: {
database: dbConfig, database: dbConfig,
}, },
database: dbConfig,
}, },
}, },
} }