diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/package.json b/plugins/node/opentelemetry-instrumentation-mongodb/package.json index 0b1eee1b62..69e921d121 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/package.json +++ b/plugins/node/opentelemetry-instrumentation-mongodb/package.json @@ -7,12 +7,15 @@ "repository": "open-telemetry/opentelemetry-js-contrib", "scripts": { "docker:start": "docker run -e MONGODB_DB=opentelemetry-tests -e MONGODB_PORT=27017 -e MONGODB_HOST=127.0.0.1 -p 27017:27017 --rm mongo", - "test": "npm run test-v5-v6", - "test-v3": "nyc mocha --require '@opentelemetry/contrib-test-utils' 'test/**/mongodb-v3.test.ts'", - "test-v4": "nyc mocha --require '@opentelemetry/contrib-test-utils' 'test/mongodb-v4-v5-v6.metrics.test.ts' 'test/**/mongodb-v4.test.ts'", - "test-v5-v6": "nyc mocha --require '@opentelemetry/contrib-test-utils' 'test/mongodb-v4-v5-v6.metrics.test.ts' 'test/**/mongodb-v5-v6.test.ts'", + "test": "npm run test-v3 && npm run test-v4 && npm run test-v5-v6 && nyc merge .nyc_output ./coverage/coverage-final.json", + "test-v3": "tav mongodb 3.7.4 npm run test-v3-run", + "test-v4": "tav mongodb 4.17.0 npm run test-v4-run", + "test-v5-v6": "npm run test-v5-v6-run", + "test-v3-run": "nyc --no-clean mocha --require '@opentelemetry/contrib-test-utils' 'test/**/mongodb-v3.test.ts'", + "test-v4-run": "nyc --no-clean mocha --require '@opentelemetry/contrib-test-utils' 'test/mongodb-v4-v5-v6.metrics.test.ts' 'test/**/mongodb-v4.test.ts'", + "test-v5-v6-run": "nyc --no-clean mocha --require '@opentelemetry/contrib-test-utils' 'test/mongodb-v4-v5-v6.metrics.test.ts' 'test/**/mongodb-v5-v6.test.ts'", "test-all-versions": "tav", - "tdd": "npm run test -- --watch-extensions ts --watch", + "tdd": "npm run test-v5-v6-run -- --watch-extensions ts --watch", "clean": "rimraf build/*", "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v3.test.ts b/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v3.test.ts index 4a3bd9a6e0..d1163315fc 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v3.test.ts +++ b/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v3.test.ts @@ -39,6 +39,9 @@ import { SEMATTRS_NET_PEER_PORT, } from '@opentelemetry/semantic-conventions'; +// We can't use @ts-expect-error because it will fail depending on the used mongodb version on tests +/* eslint-disable @typescript-eslint/ban-ts-comment */ + describe('MongoDBInstrumentation-Tracing-v3', () => { function create(config: MongoDBInstrumentationConfig = {}) { instrumentation.setConfig(config); @@ -85,7 +88,7 @@ describe('MongoDBInstrumentation-Tracing-v3', () => { } // Non traced insertion of basic data to perform tests const insertData = [{ a: 1 }, { a: 2 }, { a: 3 }]; - // @ts-expect-error -- v5 removed callback support + // @ts-ignore -- v5 removed callback support collection.insertMany(insertData, (err: any, result: any) => { resetMemoryExporter(); done(); @@ -94,7 +97,7 @@ describe('MongoDBInstrumentation-Tracing-v3', () => { afterEach(done => { if (shouldTest) { - // @ts-expect-error -- v5 removed callback support + // @ts-ignore -- v5 removed callback support collection.deleteMany({}, done); } else { done(); @@ -619,7 +622,6 @@ describe('MongoDBInstrumentation-Tracing-v3', () => { let collection: Collection; before(done => { accessCollection(URL, DB_NAME, COLLECTION_NAME, { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore useUnifiedTopology: true, }) @@ -642,7 +644,7 @@ describe('MongoDBInstrumentation-Tracing-v3', () => { it('should generate correct span attributes', done => { const span = trace.getTracer('default').startSpan('findRootSpan'); context.with(trace.setSpan(context.active(), span), () => { - // @ts-expect-error -- v5 removed callback support + // @ts-ignore -- v5 removed callback support collection.find({ a: 1 }).toArray((err, results) => { span.end(); const [mongoSpan] = getTestSpans(); @@ -723,3 +725,5 @@ describe('MongoDBInstrumentation-Tracing-v3', () => { }); }); }); + +/* eslint-enable @typescript-eslint/ban-ts-comment */ diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v4.test.ts b/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v4.test.ts index febd901776..e73a4fcf45 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v4.test.ts +++ b/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v4.test.ts @@ -37,6 +37,9 @@ import type { MongoClient, Collection } from 'mongodb'; import { assertSpans, accessCollection, DEFAULT_MONGO_HOST } from './utils'; import { SEMATTRS_DB_STATEMENT } from '@opentelemetry/semantic-conventions'; +// We can't use @ts-expect-error because it will fail depending on the used mongodb version on tests +/* eslint-disable @typescript-eslint/ban-ts-comment */ + describe('MongoDBInstrumentation-Tracing-v4', () => { function create(config: MongoDBInstrumentationConfig = {}) { instrumentation.setConfig(config); @@ -82,7 +85,7 @@ describe('MongoDBInstrumentation-Tracing-v4', () => { } // Non traced insertion of basic data to perform tests const insertData = [{ a: 1 }, { a: 2 }, { a: 3 }]; - // @ts-expect-error -- v5 removed callback support + // @ts-ignore -- v5 removed callback support collection.insertMany(insertData, (err: any, result: any) => { resetMemoryExporter(); done(); @@ -91,7 +94,7 @@ describe('MongoDBInstrumentation-Tracing-v4', () => { afterEach(done => { if (shouldTest) { - // @ts-expect-error -- v5 removed callback support + // @ts-ignore -- v5 removed callback support collection.deleteMany({}, done); } else { done(); @@ -693,3 +696,5 @@ describe('MongoDBInstrumentation-Tracing-v4', () => { }); }); }); + +/* eslint-enable @typescript-eslint/ban-ts-comment */ diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v5-v6.test.ts b/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v5-v6.test.ts index debe84dbdc..eeeae5b24a 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v5-v6.test.ts +++ b/plugins/node/opentelemetry-instrumentation-mongodb/test/mongodb-v5-v6.test.ts @@ -46,6 +46,9 @@ import type { MongoClient, Collection } from 'mongodb'; import { assertSpans, accessCollection, DEFAULT_MONGO_HOST } from './utils'; import { SEMATTRS_DB_STATEMENT } from '@opentelemetry/semantic-conventions'; +// We can't use @ts-expect-error because it will fail depending on the used mongodb version on tests +/* eslint-disable @typescript-eslint/ban-ts-comment */ + describe('MongoDBInstrumentation-Tracing-v5', () => { function create(config: MongoDBInstrumentationConfig = {}) { instrumentation.setConfig(config); @@ -706,3 +709,5 @@ describe('MongoDBInstrumentation-Tracing-v5', () => { }); }); }); + +/* eslint-enable @typescript-eslint/ban-ts-comment */