Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(test-utils): Don't swallow assertion errors from checkResult and checkCollector #2588

Merged
merged 4 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Loading