Skip to content

Commit f8e623e

Browse files
authored
chore(instrumentation-pg): skip test if db not running (#3023)
1 parent b4272de commit f8e623e

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

packages/instrumentation-pg/test/pg-pool.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,22 @@ describe('pg-pool', () => {
937937
});
938938

939939
describe('pg-pool (ESM)', () => {
940+
const testPostgres = process.env.RUN_POSTGRES_TESTS;
941+
const shouldTest = testPostgres; // Skips these tests if false (default)
942+
943+
before(function () {
944+
const skip = () => {
945+
// this.skip() workaround
946+
// https://github.com/mochajs/mocha/issues/2683#issuecomment-375629901
947+
this.test!.parent!.pending = true;
948+
this.skip();
949+
};
950+
951+
if (!shouldTest) {
952+
skip();
953+
}
954+
});
955+
940956
it('should work with ESM usage', async () => {
941957
await testUtils.runTestFixture({
942958
cwd: __dirname,

packages/instrumentation-pg/test/pg.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,22 @@ describe('pg', () => {
10871087
});
10881088

10891089
describe('pg (ESM)', () => {
1090+
const testPostgres = process.env.RUN_POSTGRES_TESTS;
1091+
const shouldTest = testPostgres; // Skips these tests if false (default)
1092+
1093+
before(function () {
1094+
const skip = () => {
1095+
// this.skip() workaround
1096+
// https://github.com/mochajs/mocha/issues/2683#issuecomment-375629901
1097+
this.test!.parent!.pending = true;
1098+
this.skip();
1099+
};
1100+
1101+
if (!shouldTest) {
1102+
skip();
1103+
}
1104+
});
1105+
10901106
it('should work with ESM usage', async () => {
10911107
await testUtils.runTestFixture({
10921108
cwd: __dirname,

0 commit comments

Comments
 (0)