mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
- We've been seeing weird errors with tables not existing when running tests locally - This appears to happen after an error causes the tests to abort - This change includes two fixes: 1. we triggers a full DB reset just before the entire test suite runs - this is done by wrapping the override file for tests that use a db, and supplying a mochaGlobalSetup hook 2. catch errors when attempting to do a fast truncation-based reset & init, and do a full reset & init instead - These two changes should ensure the DB is always in the state we expect when running a new test suite
17 lines
528 B
JavaScript
17 lines
528 B
JavaScript
/**
|
|
* This overrides file should be used for all tests that use the DB
|
|
*/
|
|
|
|
module.exports = require('./overrides');
|
|
|
|
/**
|
|
* Global Setup
|
|
* Guaranteed to only ever run once regardless of whether
|
|
* mocha is run in serial or parallel
|
|
*/
|
|
module.exports.mochaGlobalSetup = async function () {
|
|
// Actually delete the database so we start afresh
|
|
// This protects against DB errors after an aborted test run
|
|
// This technically only needs to happen before DB-related tests
|
|
await require('./db-utils').destroy();
|
|
};
|