Enabled browser-based tests to start Ghost with default test fixtures

refs: https://github.com/TryGhost/Toolbox/issues/479
This commit is contained in:
Sam Lord 2022-11-17 17:00:54 +00:00
parent bbbef3555f
commit 49605a9559
4 changed files with 29 additions and 6 deletions

View File

@ -32,7 +32,8 @@
"test:integration": "mocha --require=./test/utils/overrides.js --exit --trace-warnings --recursive --extension=test.js './test/integration' --timeout=10000",
"test:e2e": "mocha --require=./test/utils/overrides.js --exit --trace-warnings --recursive --extension=test.js './test/e2e-api' './test/e2e-frontend' './test/e2e-server' './test/e2e-webhooks' --timeout=15000",
"test:regression": "mocha --require=./test/utils/overrides.js --exit --trace-warnings --recursive --extension=test.js './test/regression' --timeout=60000",
"test:browser": "playwright test --browser=all test/e2e-browser",
"test:browser": "NODE_ENV=testing playwright test --browser=all test/e2e-browser",
"test:browser:start": "node test/e2e-browser/bin/ghost",
"test:ci": "c8 -c ./.c8rc.e2e.json yarn test:ci:base",
"test:ci:base": "yarn test:e2e -b",
"test:unit:slow": "yarn test:unit --reporter=mocha-slow-test-reporter",

View File

@ -0,0 +1,15 @@
const ghostConfig = require('./core/shared/config');
/** @type {import('@playwright/test').PlaywrightTestConfig} */
const config = {
timeout: 10 * 1000,
webServer: {
command: 'yarn test:browser:start',
url: ghostConfig.get('url')
},
use: {
baseURL: ghostConfig.get('url')
}
};
module.exports = config;

View File

@ -0,0 +1,7 @@
const testUtils = require('../../utils');
async function startGhost() {
await testUtils.startGhost();
}
startGhost();

View File

@ -1,8 +1,8 @@
const {expect, test} = require('@playwright/test');
let siteUrl = process.env.TEST_URL || 'http://localhost:2368';
test('Homepage is 200', async ({page}) => {
const response = await page.goto(siteUrl);
expect(response.status()).toEqual(200);
test.describe('Ghost frontend', function () {
test('Loads the homepage', async ({page}) => {
const response = await page.goto('/');
expect(response.status()).toEqual(200);
});
});