|
| 1 | +'use strict' |
| 2 | + |
| 3 | +const assert = require('node:assert/strict') |
| 4 | +const axios = require('axios') |
| 5 | +const { |
| 6 | + sandboxCwd, useSandbox, varySandbox, |
| 7 | + FakeAgent, spawnPluginIntegrationTestProc |
| 8 | +} = require('../../../../integration-tests/helpers') |
| 9 | +const { withVersions } = require('../../../dd-trace/test/setup/mocha') |
| 10 | + |
| 11 | +withVersions('body-parser', 'body-parser', version => { |
| 12 | + describe('ESM', () => { |
| 13 | + let variants, proc, agent |
| 14 | + |
| 15 | + useSandbox([`'body-parser@${version}'`, 'express'], false, |
| 16 | + ['./packages/datadog-plugin-body-parser/test/integration-test/*']) |
| 17 | + |
| 18 | + before(function () { |
| 19 | + variants = varySandbox('server.mjs', 'bodyParser', undefined, 'body-parser') |
| 20 | + }) |
| 21 | + |
| 22 | + beforeEach(async () => { |
| 23 | + agent = await new FakeAgent().start() |
| 24 | + }) |
| 25 | + |
| 26 | + afterEach(async () => { |
| 27 | + proc?.kill() |
| 28 | + await agent.stop() |
| 29 | + }) |
| 30 | + |
| 31 | + for (const variant of varySandbox.VARIANTS) { |
| 32 | + it(`is instrumented ${variant}`, async () => { |
| 33 | + proc = await spawnPluginIntegrationTestProc(sandboxCwd(), variants[variant], agent.port) |
| 34 | + const response = await axios.post(`${proc.url}/`, { key: 'value' }) |
| 35 | + assert.equal(response.headers['x-counter'], '1') |
| 36 | + }) |
| 37 | + } |
| 38 | + }) |
| 39 | +}) |
0 commit comments