Skip to content

Commit 5c2526f

Browse files
committed
feat: replace console.log with debug
closes #105
1 parent 42a8143 commit 5c2526f

File tree

5 files changed

+12
-4
lines changed

5 files changed

+12
-4
lines changed

environment.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ const path = require('path');
33
const fs = require('fs');
44
const globalConfigPath = path.join(__dirname, 'globalConfig.json');
55

6+
const debug = require('debug')('jest-mongodb:environment');
7+
68
module.exports = class MongoEnvironment extends NodeEnvironment {
79
constructor(config) {
810
super(config);
911
}
1012

1113
async setup() {
12-
console.log('Setup MongoDB Test Environment');
14+
debug('Setup MongoDB Test Environment');
1315

1416
const globalConfig = JSON.parse(fs.readFileSync(globalConfigPath, 'utf-8'));
1517

@@ -20,7 +22,7 @@ module.exports = class MongoEnvironment extends NodeEnvironment {
2022
}
2123

2224
async teardown() {
23-
console.log('Teardown MongoDB Test Environment');
25+
debug('Teardown MongoDB Test Environment');
2426

2527
await super.teardown();
2628
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
],
2626
"dependencies": {
2727
"cwd": "0.10.0",
28+
"debug": "4.1.1",
2829
"mongodb": "3.2.3",
2930
"mongodb-memory-server": "5.1.0"
3031
},

readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ it('should insert a doc into collection', async () => {
7373

7474
Cache MongoDB binary in CI by putting this folder to the list of cached paths: `./node_modules/.cache/mongodb-memory-server/mongodb-binaries`
7575

76+
You can enable debug logs by setting environment variable `DEBUG=jest-mongodb:*`
77+
7678
## See Also
7779

7880
- [jest-dynamodb](https://github.com/shelfio/jest-dynamodb)

setup.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const cwd = require('cwd');
44
const MongodbMemoryServer = require('mongodb-memory-server');
55
const globalConfigPath = join(__dirname, 'globalConfig.json');
66

7+
const debug = require('debug')('jest-mongodb:setup');
78
const mongod = new MongodbMemoryServer.default(getMongodbMemoryOptions());
89

910
module.exports = async () => {
@@ -18,7 +19,7 @@ module.exports = async () => {
1819

1920
// Write global config to disk because all tests run in different contexts.
2021
fs.writeFileSync(globalConfigPath, JSON.stringify(mongoConfig));
21-
console.log('Config is written');
22+
debug('Config is written');
2223

2324
// Set reference to mongod in order to close the server during teardown.
2425
global.__MONGOD__ = mongod;

teardown.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
const debug = require('debug')('jest-mongodb:teardown');
2+
13
module.exports = async function() {
2-
console.log('Teardown mongod');
4+
debug('Teardown mongod');
35
await global.__MONGOD__.stop();
46
};

0 commit comments

Comments
 (0)