Skip to content

Commit

Permalink
test(instr-koa): lint tests
Browse files Browse the repository at this point in the history
  • Loading branch information
david-luna committed Nov 28, 2024
1 parent 5b44293 commit aef2c80
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions plugins/node/opentelemetry-instrumentation-koa/test/koa.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 };
Expand Down Expand Up @@ -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 };
Expand Down Expand Up @@ -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'],
Expand Down

0 comments on commit aef2c80

Please sign in to comment.