Skip to content

Commit

Permalink
backend adjust jest integration tests setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkzarich committed Dec 29, 2024
1 parent c85f93f commit 0db9072
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
1 change: 1 addition & 0 deletions packages/server/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const config = {
// Runs after the test framework has been installed in the environment. Before each spec file.
setupFilesAfterEnv: ['./src/tests/jest.setup-after-env.js'],
watchPathIgnorePatterns: ['node_modules'],
testTimeout: 30000,
};

export default config;
2 changes: 1 addition & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"pnpm": ">=8.6.0"
},
"scripts": {
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest --runInBand",
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest --runInBand --forceExit --detectOpenHandles",
"start": "node index.js",
"dev": "nodemon index.js",
"gen-doc": "pnpm exec swagger-jsdoc -d src/swagger/swaggerDef.js -o \"src/swagger/swagger.json\"",
Expand Down
12 changes: 4 additions & 8 deletions packages/server/src/tests/jest.setup-after-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@ beforeAll(async () => {
global.app = await App.startApp();
});

afterAll(async () => {
if (mongoose.connection.readyState === 1) {
await mongoose.connection.close();
}
beforeEach(async () => {
await mongoose.connections[0].dropDatabase();
});

beforeEach(async () => {
if (mongoose.connection.readyState === 1) {
await mongoose.connection.dropDatabase();
}
afterAll(async () => {
await mongoose.connections[0].close();
});
3 changes: 3 additions & 0 deletions packages/server/src/tests/jest.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ export default async () => {
}

const mongod = await MongoMemoryServer.create({
instance: {
port: 27018,
},
binary: {
version: '5.0.10',
},
Expand Down

0 comments on commit 0db9072

Please sign in to comment.