Fixed & unskipped subdirectory tests w/ new boot

refs: f1be3418d9

- Since I refactored the boot process & subsequently the test tools, I have been hitting an issue where subdirectory tests don't work if the app has already been started without a subdirectory
- Turns out it's due to the rootApp getting cached, and not replaced no matter what you do, even though if you debug it _looks_ like it's been replaced
- This makes sense as the rootApp is in a separate file and therefore subject to the node module cache and we're using const everywhere
- Therefore, I have added a single line to the test utils to destroy this cache for this file, and the tests now work perfectly
- Next: refactor the test utilities some more to make all this much, much more straightforward and easy to understand
This commit is contained in:
Hannah Wolfe 2021-05-26 14:31:21 +01:00
parent 1b26692430
commit 49f20820ef
No known key found for this signature in database
GPG Key ID: 9F8C7532D0A6BA55
2 changed files with 5 additions and 6 deletions

View File

@ -293,7 +293,7 @@ describe('Frontend Routing', function () {
});
// @TODO: unskip this, need to fix rebooting ghost with a subdirectory
describe.skip('Subdirectory (no slash)', function () {
describe('Subdirectory (no slash)', function () {
let ghostServer;
before(function () {
@ -374,7 +374,7 @@ describe('Frontend Routing', function () {
});
// @TODO: unskip this, need to fix rebooting ghost with a subdirectory
describe.skip('Subdirectory (with slash)', function () {
describe('Subdirectory (with slash)', function () {
let ghostServer;
before(function () {
@ -790,7 +790,7 @@ describe('Frontend Routing', function () {
});
// @TODO: unskip this, need to fix rebooting ghost with a subdirectory
describe.skip(`Subdirectory redirects (use redirects${ext} from test/utils/fixtures/data)`, function () {
describe(`Subdirectory redirects (use redirects${ext} from test/utils/fixtures/data)`, function () {
var ghostServer;
before(function () {

View File

@ -231,9 +231,7 @@ const freshModeGhostStart = async (options) => {
await knexMigrator.reset({force: true});
// Stop the serve (forceStart Mode)
if (ghostServer && ghostServer.httpServer) {
await ghostServer.stop();
}
await stopGhost();
// Reset the settings cache
// @TODO: Prob A: why/how is this different to using settingsService.init() and why to do we need this?
@ -290,6 +288,7 @@ const startGhost = async (options) => {
const stopGhost = async () => {
if (ghostServer && ghostServer.httpServer) {
await ghostServer.stop();
delete require.cache[require.resolve('../../core/app')];
urlService.resetGenerators();
}
};