Skip to content

Commit de679ad

Browse files
fix(test-utils): Don't swallow assertion errors from checkResult and checkCollector (#2588)
Co-authored-by: Marc Pichler <[email protected]>
1 parent baccd98 commit de679ad

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

packages/opentelemetry-test-utils/src/test-fixtures.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ export async function runTestFixture(
236236
const collector = new TestCollector();
237237
await collector.start();
238238

239-
return new Promise(resolve => {
239+
return new Promise((resolve, reject) => {
240240
execFile(
241241
process.execPath,
242242
opts.argv,
@@ -261,6 +261,8 @@ export async function runTestFixture(
261261
if (opts.checkCollector) {
262262
await opts.checkCollector(collector);
263263
}
264+
} catch (err) {
265+
reject(err);
264266
} finally {
265267
collector.close();
266268
resolve();

plugins/node/opentelemetry-instrumentation-hapi/test/hapi.test.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,15 +557,24 @@ describe('Hapi Instrumentation - Core Tests', () => {
557557
},
558558
checkCollector: (collector: TestCollector) => {
559559
const spans = collector.sortedSpans;
560-
assert.strictEqual(spans.length, 2);
561-
assert.strictEqual(spans[0].name, 'GET /route/{param}');
560+
561+
assert.strictEqual(spans.length, 3);
562+
563+
assert.strictEqual(spans[0].name, 'GET');
562564
assert.strictEqual(
563565
spans[0].instrumentationScope.name,
564566
'@opentelemetry/instrumentation-http'
565567
);
566-
assert.strictEqual(spans[1].name, 'route - /route/{param}');
568+
569+
assert.strictEqual(spans[1].name, 'GET /route/{param}');
567570
assert.strictEqual(
568571
spans[1].instrumentationScope.name,
572+
'@opentelemetry/instrumentation-http'
573+
);
574+
575+
assert.strictEqual(spans[2].name, 'route - /route/{param}');
576+
assert.strictEqual(
577+
spans[2].instrumentationScope.name,
569578
'@opentelemetry/instrumentation-hapi'
570579
);
571580
},

0 commit comments

Comments
 (0)