Started a greenfield e2e test framework

refs https://github.com/TryGhost/Toolbox/issues/129

- Having a fresh module should allow building new testing utility concepts from the ground up without being tied by the mystery baggage of the legacy localUtils/testUtils
- The outline of the concepts the framework will be handling is in the commont on the top of the e2e-framework file
This commit is contained in:
Naz 2021-12-07 13:51:08 +04:00 committed by naz
parent a18fa18ff3
commit 6762e2a60d
2 changed files with 38 additions and 1 deletions

View File

@ -1,4 +1,5 @@
const should = require('should');
const framework = require('../../../../utils/e2e-framework');
const testUtils = require('../../../../utils');
const localUtils = require('./utils');
const config = require('../../../../../core/shared/config');
@ -7,7 +8,7 @@ describe('Config API', function () {
let request;
before(async function () {
request = await localUtils.getAuthenticatedAgent();
request = await framework.getAgent();
});
it('can retrieve config and all expected properties', async function () {

View File

@ -0,0 +1,36 @@
// Set of common function that should be main building blocks for e2e tests.
// The e2e tests usually consist of following building blocks:
// - request agent
// - state builder
// - output state checker
//
// The request agetnt is responsible for making HTTP-like requests to an application (express app in case of Ghost).
// Note there's no actual need to make an HTTP request to an actual server, bypassing HTTP and hooking into the application
// directly is enough and reduces dependence on blocking a port (allows to run tests in parallel).
//
// The state builder is responsible for building the state of the application. Usually it's done by using pre-defined fixtures.
// Can include building a DB state, file system state (themes, config files), building configuration state (config files) etc.
//
// The output state checker is responsible for checking the response from the app after performing a request.
const supertest = require('supertest');
const boot = require('../../core/boot');
const startGhost = () => {
const defaults = {
backend: true,
frontend: false,
server: false
};
return boot(defaults);
};
const getAgent = async () => {
const app = await startGhost();
return supertest.agent(app);
};
module.exports.getAgent = getAgent;