Skip to content

Commit

Permalink
fix(test-utils): Don't swallow assertion errors from checkResult an…
Browse files Browse the repository at this point in the history
…d `checkCollector` (#2588)

Co-authored-by: Marc Pichler <[email protected]>
  • Loading branch information
onurtemizkan and pichlermarc authored Dec 6, 2024
1 parent baccd98 commit de679ad
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 3 additions & 1 deletion packages/opentelemetry-test-utils/src/test-fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export async function runTestFixture(
const collector = new TestCollector();
await collector.start();

return new Promise(resolve => {
return new Promise((resolve, reject) => {
execFile(
process.execPath,
opts.argv,
Expand All @@ -261,6 +261,8 @@ export async function runTestFixture(
if (opts.checkCollector) {
await opts.checkCollector(collector);
}
} catch (err) {
reject(err);
} finally {
collector.close();
resolve();
Expand Down
15 changes: 12 additions & 3 deletions plugins/node/opentelemetry-instrumentation-hapi/test/hapi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -557,15 +557,24 @@ describe('Hapi Instrumentation - Core Tests', () => {
},
checkCollector: (collector: TestCollector) => {
const spans = collector.sortedSpans;
assert.strictEqual(spans.length, 2);
assert.strictEqual(spans[0].name, 'GET /route/{param}');

assert.strictEqual(spans.length, 3);

assert.strictEqual(spans[0].name, 'GET');
assert.strictEqual(
spans[0].instrumentationScope.name,
'@opentelemetry/instrumentation-http'
);
assert.strictEqual(spans[1].name, 'route - /route/{param}');

assert.strictEqual(spans[1].name, 'GET /route/{param}');
assert.strictEqual(
spans[1].instrumentationScope.name,
'@opentelemetry/instrumentation-http'
);

assert.strictEqual(spans[2].name, 'route - /route/{param}');
assert.strictEqual(
spans[2].instrumentationScope.name,
'@opentelemetry/instrumentation-hapi'
);
},
Expand Down

0 comments on commit de679ad

Please sign in to comment.