diff --git a/dev-packages/node-integration-tests/package.json b/dev-packages/node-integration-tests/package.json index c98722e16a0b..01deaadcc7de 100644 --- a/dev-packages/node-integration-tests/package.json +++ b/dev-packages/node-integration-tests/package.json @@ -16,12 +16,9 @@ "build:types": "tsc -p tsconfig.types.json", "clean": "rimraf -g **/node_modules && run-p clean:script", "clean:script": "node scripts/clean.js", - "prisma-v5:init": "cd suites/tracing/prisma-orm-v5 && yarn && yarn setup", - "prisma-v6:init": "cd suites/tracing/prisma-orm-v6 && yarn && yarn setup", "lint": "eslint . --format stylish", "fix": "eslint . --format stylish --fix", "type-check": "tsc", - "pretest": "run-s --silent prisma-v5:init prisma-v6:init", "test": "jest --config ./jest.config.js", "test:watch": "yarn test --watch" }, diff --git a/dev-packages/node-integration-tests/suites/tracing/prisma-orm-v5/package.json b/dev-packages/node-integration-tests/suites/tracing/prisma-orm-v5/package.json index b8721038c83b..d3dcaf9d1328 100644 --- a/dev-packages/node-integration-tests/suites/tracing/prisma-orm-v5/package.json +++ b/dev-packages/node-integration-tests/suites/tracing/prisma-orm-v5/package.json @@ -7,10 +7,9 @@ "node": ">=18" }, "scripts": { - "db-up": "docker compose up -d", "generate": "prisma generate", "migrate": "prisma migrate dev -n sentry-test", - "setup": "run-s --silent db-up generate migrate" + "setup": "run-s --silent generate migrate" }, "keywords": [], "author": "", diff --git a/dev-packages/node-integration-tests/suites/tracing/prisma-orm-v5/test.ts b/dev-packages/node-integration-tests/suites/tracing/prisma-orm-v5/test.ts index 0ece02f2f1cb..6f51fe329bbc 100644 --- a/dev-packages/node-integration-tests/suites/tracing/prisma-orm-v5/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/prisma-orm-v5/test.ts @@ -1,8 +1,17 @@ -import { createRunner } from '../../../utils/runner'; +import { cleanupChildProcesses, createRunner } from '../../../utils/runner'; -describe('Prisma ORM Tests', () => { +afterAll(() => { + cleanupChildProcesses(); +}); + +describe('Prisma ORM v5 Tests', () => { test('CJS - should instrument PostgreSQL queries from Prisma ORM', done => { createRunner(__dirname, 'scenario.js') + .withDockerCompose({ + workingDirectory: [__dirname], + readyMatches: ['port 5432'], + setupCommand: 'yarn && yarn setup', + }) .expect({ transaction: transaction => { expect(transaction.transaction).toBe('Test Transaction'); diff --git a/dev-packages/node-integration-tests/suites/tracing/prisma-orm-v6/package.json b/dev-packages/node-integration-tests/suites/tracing/prisma-orm-v6/package.json index a0b24c52e319..dc062f1b9e3b 100644 --- a/dev-packages/node-integration-tests/suites/tracing/prisma-orm-v6/package.json +++ b/dev-packages/node-integration-tests/suites/tracing/prisma-orm-v6/package.json @@ -7,10 +7,9 @@ "node": ">=18" }, "scripts": { - "db-up": "docker compose up -d", "generate": "prisma generate", "migrate": "prisma migrate dev -n sentry-test", - "setup": "run-s --silent db-up generate migrate" + "setup": "run-s --silent generate migrate" }, "keywords": [], "author": "", diff --git a/dev-packages/node-integration-tests/suites/tracing/prisma-orm-v6/test.ts b/dev-packages/node-integration-tests/suites/tracing/prisma-orm-v6/test.ts index 70d2fda9cbe0..34214858d8ff 100644 --- a/dev-packages/node-integration-tests/suites/tracing/prisma-orm-v6/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/prisma-orm-v6/test.ts @@ -1,9 +1,18 @@ import type { SpanJSON } from '@sentry/core'; -import { createRunner } from '../../../utils/runner'; +import { cleanupChildProcesses, createRunner } from '../../../utils/runner'; -describe('Prisma ORM Tests', () => { +afterAll(() => { + cleanupChildProcesses(); +}); + +describe('Prisma ORM v6 Tests', () => { test('CJS - should instrument PostgreSQL queries from Prisma ORM', done => { createRunner(__dirname, 'scenario.js') + .withDockerCompose({ + workingDirectory: [__dirname], + readyMatches: ['port 5432'], + setupCommand: 'yarn && yarn setup', + }) .expect({ transaction: transaction => { expect(transaction.transaction).toBe('Test Transaction'); diff --git a/dev-packages/node-integration-tests/utils/runner.ts b/dev-packages/node-integration-tests/utils/runner.ts index a5fc8df38825..152160f7118b 100644 --- a/dev-packages/node-integration-tests/utils/runner.ts +++ b/dev-packages/node-integration-tests/utils/runner.ts @@ -1,5 +1,5 @@ /* eslint-disable max-lines */ -import { spawn, spawnSync } from 'child_process'; +import { execSync, spawn, spawnSync } from 'child_process'; import { existsSync } from 'fs'; import { join } from 'path'; import { normalize } from '@sentry/core'; @@ -60,6 +60,10 @@ interface DockerOptions { * The strings to look for in the output to know that the docker compose is ready for the test to be run */ readyMatches: string[]; + /** + * The command to run after docker compose is up + */ + setupCommand?: string; } /** @@ -96,6 +100,9 @@ async function runDockerCompose(options: DockerOptions): Promise { if (text.includes(match)) { child.stdout.removeAllListeners(); clearTimeout(timeout); + if (options.setupCommand) { + execSync(options.setupCommand, { cwd, stdio: 'inherit' }); + } resolve(close); } }