mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 14:03:48 +03:00
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:
parent
a18fa18ff3
commit
6762e2a60d
@ -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 () {
|
||||
|
36
test/utils/e2e-framework.js
Normal file
36
test/utils/e2e-framework.js
Normal 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;
|
Loading…
Reference in New Issue
Block a user