Skip to content

Commit

Permalink
Silence logging from migrations when setting up database in testing (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-white authored Jul 20, 2023
1 parent 5c27f00 commit facf339
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/integration/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { sql } = require('slonik');
const { readdirSync } = require('fs');
const { join } = require('path');
const request = require('supertest');
const { noop } = require(appRoot + '/lib/util/util');
// eslint-disable-next-line import/no-dynamic-require
const { task } = require(appRoot + '/lib/task/task');

Expand Down Expand Up @@ -79,10 +80,14 @@ const populate = (container, [ head, ...tail ] = fixtures) =>
// in that case.
const initialize = async () => {
const migrator = connect(config.get('test.database'));
const { log } = console;
try {
await migrator.raw('drop owned by current_user');
// Silence logging from migrations.
console.log = noop; // eslint-disable-line no-console
await migrator.migrate.latest({ directory: appRoot + '/lib/model/migrations' });
} finally {
console.log = log; // eslint-disable-line no-console
await migrator.destroy();
}

Expand Down

0 comments on commit facf339

Please sign in to comment.