Skip to content

Commit

Permalink
fix discord bot tests for new JSON API version
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Jan 4, 2024
1 parent dfefbbf commit f3b2223
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion discord-bot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"lint": "eslint .",
"test": "mocha test/*.js",
"test": "mocha --exit test/*.js",
"start": "node ./index.js"
},
"author": "",
Expand Down
9 changes: 7 additions & 2 deletions discord-bot/test/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require('dotenv').config({ path: `${__dirname}/../.env.test` });

const Bot = require('../models/bot');
const { before } = require('mocha');
const { after, before } = require('mocha');
const mongoose = require('../mongoose');

const uri = process.env.JSON_API_URL;
Expand All @@ -14,8 +14,13 @@ const jsonApiConnectOptions = {
};

before(async function() {
console.log('Connecting to', uri);
this.timeout(15000);
await mongoose.connect(uri, jsonApiConnectOptions);
// dropCollection() can be slower
await Bot.db.dropCollection('bots').catch(() => {});
await Bot.createCollection();
});

after(async function() {
await mongoose.disconnect();
});

0 comments on commit f3b2223

Please sign in to comment.