From aef2c8000f9367a46b6ea0e8be61b3208b1188d2 Mon Sep 17 00:00:00 2001 From: David Luna Date: Thu, 28 Nov 2024 13:01:23 +0100 Subject: [PATCH] test(instr-koa): lint tests --- .../test/koa.test.ts | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/plugins/node/opentelemetry-instrumentation-koa/test/koa.test.ts b/plugins/node/opentelemetry-instrumentation-koa/test/koa.test.ts index b047165477..c1b894a026 100644 --- a/plugins/node/opentelemetry-instrumentation-koa/test/koa.test.ts +++ b/plugins/node/opentelemetry-instrumentation-koa/test/koa.test.ts @@ -68,7 +68,9 @@ const httpRequest = { const LIB_VERSION = require('@koa/router/package.json').version; const NODE_VERSION = process.version; -const routerCompat = semver.gte(LIB_VERSION, '13.0.0') && semver.gte(NODE_VERSION, '18.0.0') +const isrouterCompat = + semver.lt(LIB_VERSION, '13.0.0') || + (semver.gte(LIB_VERSION, '13.0.0') && semver.gte(NODE_VERSION, '18.0.0')); describe('Koa Instrumentation', function () { const provider = new NodeTracerProvider(); @@ -146,12 +148,13 @@ describe('Koa Instrumentation', function () { yield next; }; - describe('Instrumenting @koa/router calls', function() { - before(function() { - if (!routerCompat) { + describe('Instrumenting @koa/router calls', function () { + before(function () { + if (!isrouterCompat) { this.skip(); } }); + it('should create a child span for middlewares (string route)', async () => { const rootSpan = tracer.startSpan('rootSpan'); const rpcMetadata: RPCMetadata = { type: RPCType.HTTP, span: rootSpan }; @@ -595,7 +598,13 @@ describe('Koa Instrumentation', function () { }); }); - describe('Using requestHook', () => { + describe('Using requestHook', function () { + before(function () { + if (!isrouterCompat) { + this.skip(); + } + }); + it('should ignore requestHook which throws exception', async () => { const rootSpan = tracer.startSpan('rootSpan'); const rpcMetadata = { type: RPCType.HTTP, span: rootSpan }; @@ -731,7 +740,8 @@ describe('Koa Instrumentation', function () { }); }); - it('should work with ESM usage', async () => { + const itFn = isrouterCompat ? it : it.skip; + itFn('should work with ESM usage', async () => { await testUtils.runTestFixture({ cwd: __dirname, argv: ['fixtures/use-koa.mjs'],