Skip to content

Commit cc6c3a2

Browse files
committed
sync db before tests
1 parent c8a79eb commit cc6c3a2

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"apidoc": "apidoc -i src -o docs",
4949
"prestart": "npm run build && npm run apidoc",
5050
"start": "cross-env NODE_PATH=dist scripts/wait-for-it.sh localhost:5672 -- node dist/run.js",
51-
"test": "cross-env NODE_PATH=src NODE_ENV=test mocha --timeout 12000 --exit --require ts-node/register test/unit/validators/*.ts test/e2e/*.ts",
51+
"test": "cross-env NODE_PATH=src NODE_ENV=test mocha --timeout 12000 --exit --require ts-node/register test/utils/setup*.ts test/unit/validators/*.ts test/e2e/*.ts",
5252
"cover": "nyc npm test",
5353
"seedlangs": "node dist/scripts/seed-defaultlangs.js",
5454
"precodecov": "npm run cover",

test/utils/setup-db.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import DB from '../../src/models'
2+
import * as debug from 'debug'
3+
4+
const log = debug('test:judge:api')
5+
6+
before(async () => {
7+
await DB.sequelize.sync();
8+
log('DB synced');
9+
});
10+
11+
after(async () => {
12+
await DB.sequelize.close();
13+
});

0 commit comments

Comments
 (0)