Skip to content

Commit

Permalink
Move tests
Browse files Browse the repository at this point in the history
  • Loading branch information
onurtemizkan committed Dec 6, 2024
1 parent 21840f9 commit 44e37ea
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const sdk = createTestNodeSdk({
sdk.start();

import pg from 'pg';

const client = new pg.Client(CONFIG);

await client.connect();
Expand Down
73 changes: 0 additions & 73 deletions plugins/node/opentelemetry-instrumentation-pg/test/pg.esm.test.ts

This file was deleted.

27 changes: 27 additions & 0 deletions plugins/node/opentelemetry-instrumentation-pg/test/pg.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1087,4 +1087,31 @@ describe('pg', () => {
});
});
});

it('should work with ESM usage', async () => {
await testUtils.runTestFixture({
cwd: __dirname,
argv: ['fixtures/use-pg.mjs'],
env: {
NODE_OPTIONS:
'--experimental-loader=@opentelemetry/instrumentation/hook.mjs',
NODE_NO_WARNINGS: '1',
},
checkResult: (err, stdout, stderr) => {
assert.ifError(err);
},
checkCollector: (collector: testUtils.TestCollector) => {
const spans = collector.sortedSpans;

assert.strictEqual(spans.length, 3);

assert.strictEqual(spans[0].name, 'pg.connect');
assert.strictEqual(spans[0].kind, 3);
assert.strictEqual(spans[1].name, 'test-span');
assert.strictEqual(spans[1].kind, 1);
assert.strictEqual(spans[2].name, 'pg.query:SELECT postgres');
assert.strictEqual(spans[2].kind, 3);
},
});
});
});

0 comments on commit 44e37ea

Please sign in to comment.