Skip to content

Commit b7e388a

Browse files
Christian Jeschkevladholubiev
authored andcommitted
test: fixing test and linting errors
1 parent 7447dd4 commit b7e388a

11 files changed

+19
-40
lines changed

jest-preset.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// eslint-disable-next-line @typescript-eslint/no-require-imports
12
const preset = require('./lib').default;
23

34
module.exports = preset;

readme.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,7 @@ describe('insert', () => {
134134
let db;
135135

136136
beforeAll(async () => {
137-
connection = await MongoClient.connect(global.__MONGO_URI__, {
138-
useNewUrlParser: true,
139-
useUnifiedTopology: true,
140-
});
137+
connection = await MongoClient.connect(global.__MONGO_URI__, {});
141138
db = await connection.db();
142139
});
143140

src/environment.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type {EnvironmentContext} from '@jest/environment';
77
import type {JestEnvironmentConfig} from '@jest/environment';
88
import {getMongodbMemoryOptions, isMongoMemoryReplSetOptions} from './helpers';
99

10+
// eslint-disable-next-line @typescript-eslint/no-require-imports
1011
const debug = require('debug')('jest-mongodb:environment');
1112

1213
module.exports = class MongoEnvironment extends TestEnvironment {
@@ -49,9 +50,9 @@ module.exports = class MongoEnvironment extends TestEnvironment {
4950
await super.teardown();
5051
}
5152

52-
// @ts-ignore
53+
// @ts-expect-error - runScript has incompatible type definitions
5354
runScript(script) {
54-
// @ts-ignore
55+
// @ts-expect-error - parent class method call
5556
return super.runScript(script);
5657
}
5758
};

src/helpers.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export function getMongodbMemoryOptions(
1717
cwd: string
1818
): MongoMemoryReplSetOpts | MongoMemoryServerOpts | undefined {
1919
try {
20+
// eslint-disable-next-line @typescript-eslint/no-require-imports
2021
const {mongodbMemoryServerOptions}: Config = require(resolve(cwd, configFile));
2122

2223
return mongodbMemoryServerOptions;
@@ -32,24 +33,26 @@ export function getMongodbMemoryOptions(
3233

3334
export function getMongoURLEnvName(cwd: string) {
3435
try {
36+
// eslint-disable-next-line @typescript-eslint/no-require-imports
3537
const {mongoURLEnvName}: Config = require(resolve(cwd, configFile));
3638

3739
return mongoURLEnvName || 'MONGO_URL';
38-
} catch (e) {
40+
} catch {
3941
return 'MONGO_URL';
4042
}
4143
}
4244

4345
export function shouldUseSharedDBForAllJestWorkers(cwd: string) {
4446
try {
47+
// eslint-disable-next-line @typescript-eslint/no-require-imports
4548
const {useSharedDBForAllJestWorkers}: Config = require(resolve(cwd, configFile));
4649

4750
if (typeof useSharedDBForAllJestWorkers === 'undefined') {
4851
return true;
4952
}
5053

5154
return useSharedDBForAllJestWorkers;
52-
} catch (e) {
55+
} catch {
5356
return true;
5457
}
5558
}

src/setup.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import {
1111
} from './helpers';
1212
import {isMongoMemoryReplSetOptions} from './helpers';
1313

14-
const debug = require('debug')('jest-mongodb:setup');
14+
// eslint-disable-next-line @typescript-eslint/no-require-imports
15+
const debug = require('debug')('jest-mongodb:environment');
1516

1617
module.exports = async (config: JestEnvironmentConfig['globalConfig']) => {
1718
const globalConfigPath = join(config.rootDir, 'globalConfig.json');

src/teardown.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import {join} from 'path';
22
import {unlink} from 'fs';
33
import type {JestEnvironmentConfig} from '@jest/environment';
44

5-
const debug = require('debug')('jest-mongodb:teardown');
5+
// eslint-disable-next-line @typescript-eslint/no-require-imports
6+
const debug = require('debug')('jest-mongodb:environment');
67

78
module.exports = async function (config: JestEnvironmentConfig['globalConfig']) {
89
const globalConfigPath = join(config.rootDir, 'globalConfig.json');

test/mongo-aggregate.test.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@ describe('insert', () => {
88
let db: Db;
99

1010
beforeAll(async () => {
11-
// @ts-ignore
12-
connection = await MongoClient.connect(uri, {
13-
// @ts-ignore
14-
useNewUrlParser: true,
15-
useUnifiedTopology: true,
16-
});
11+
connection = await MongoClient.connect(uri, {});
1712
db = await connection.db();
1813
});
1914

test/mongo-insert.test.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@ describe('insert', () => {
88
let db: Db;
99

1010
beforeAll(async () => {
11-
// @ts-ignore
12-
connection = await MongoClient.connect(uri, {
13-
// @ts-ignore
14-
useNewUrlParser: true,
15-
useUnifiedTopology: true,
16-
});
11+
connection = await MongoClient.connect(uri, {});
1712
db = await connection.db();
1813
});
1914

test/mongo-parallelism.test.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@ describe('parallelism: first worker', () => {
99
let db: Db;
1010

1111
beforeAll(async () => {
12-
// @ts-ignore
13-
connection = await MongoClient.connect(uri, {
14-
// @ts-ignore
15-
useNewUrlParser: true,
16-
useUnifiedTopology: true,
17-
});
12+
connection = await MongoClient.connect(uri, {});
1813
db = await connection.db();
1914
});
2015

test/mongo-parallelism2.test.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@ describe('parallelism: second worker', () => {
99
let db: Db;
1010

1111
beforeAll(async () => {
12-
// @ts-ignore
13-
connection = await MongoClient.connect(uri, {
14-
// @ts-ignore
15-
useNewUrlParser: true,
16-
useUnifiedTopology: true,
17-
});
12+
connection = await MongoClient.connect(uri, {});
1813
db = await connection.db();
1914
});
2015

0 commit comments

Comments
 (0)