|
| 1 | +'use strict' |
| 2 | + |
| 3 | +const { |
| 4 | + createSandbox, varySandbox, |
| 5 | + FakeAgent, spawnPluginIntegrationTestProc |
| 6 | +} = require('../../../../integration-tests/helpers') |
| 7 | +const { assert } = require('chai') |
| 8 | +const { withVersions } = require('../../../dd-trace/test/setup/mocha') |
| 9 | +const axios = require('axios') |
| 10 | +withVersions('express-mongo-sanitize', 'express-mongo-sanitize', version => { |
| 11 | + describe('ESM', () => { |
| 12 | + let sandbox, variants, proc, agent |
| 13 | + |
| 14 | + before(async function () { |
| 15 | + this.timeout(50000) |
| 16 | + sandbox = await createSandbox([`'express-mongo-sanitize@${version}'`, 'express@<=4.0.0'], false, |
| 17 | + ['./packages/datadog-plugin-express-mongo-sanitize/test/integration-test/*']) |
| 18 | + variants = varySandbox(sandbox, 'server.mjs', 'expressMongoSanitize', undefined, 'express-mongo-sanitize') |
| 19 | + }) |
| 20 | + |
| 21 | + after(async function () { |
| 22 | + this.timeout(50000) |
| 23 | + await sandbox.remove() |
| 24 | + }) |
| 25 | + |
| 26 | + beforeEach(async () => { |
| 27 | + agent = await new FakeAgent().start() |
| 28 | + }) |
| 29 | + |
| 30 | + afterEach(async () => { |
| 31 | + proc?.kill() |
| 32 | + await agent.stop() |
| 33 | + }) |
| 34 | + |
| 35 | + for (const variant of varySandbox.VARIANTS) { |
| 36 | + it(`is instrumented loaded with ${variant}`, async () => { |
| 37 | + const proc = await spawnPluginIntegrationTestProc(sandbox.folder, variants[variant], agent.port) |
| 38 | + const response = await axios.get(`${proc.url}/?param=paramvalue`) |
| 39 | + assert.equal(response.headers['x-counter'], '1') |
| 40 | + }) |
| 41 | + } |
| 42 | + }) |
| 43 | +}) |
0 commit comments