Skip to content

Commit

Permalink
Added Database cleaner
Browse files Browse the repository at this point in the history
  • Loading branch information
Ehbraheem committed Feb 4, 2020
1 parent df6f066 commit f410714
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 4 additions & 2 deletions scaffold/service/package.json.replace
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
"setupFiles": [
"babel-polyfill",
"./test/jest/consoleErrorsThrowException.js"
]
],
"setupFilesAfterEnv": ['<rootDir>/test/jest/databaseCleaner.js']
},
"files": [
"lib"
Expand All @@ -56,11 +57,12 @@
"babel-eslint": "8.2.6",
"babel-jest": "23.4.2",
"concurrently": "3.6.1",
"database-cleaner": "1.3.0",
"eslint": "5.3.0",
"factory-girl": "5.0.4",
"eslint-config-airbnb": "17.1.0",
"eslint-plugin-import": "2.13.0",
"eslint-plugin-jest": "21.20.2",
"factory-girl": "5.0.4",
"flow-bin": "0.78.0",
"flow-typed": "2.5.1",
"jest": "23.5.0",
Expand Down
11 changes: 11 additions & 0 deletions scaffold/service/test/jest/databaseCleaner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import mongoose from 'mongoose';
import Cleaner from 'database-cleaner';

var dbCleaner = new Cleaner('mongodb');


afterEach(done => {
(mongoose.connection.db && dbCleaner.clean(mongoose.connection.db, () => {
done()
})) || done() // short-circuit if we're not connected
});

0 comments on commit f410714

Please sign in to comment.