0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-25 02:31:59 -05:00
ghost/ghost/core/playwright.config.js
Sam Lord 40903c3136 Fixed browser-based tests in local context
no issue

Local tests can now setup Stripe during the global setup process, and the webhook server is run out-of-process.
Running tests in CI against localhost will use environment variables to setup Stripe.
Providing a test URL will avoid setting up Stripe and will assume that it is already done.
2022-12-02 17:04:04 +00:00

38 lines
1.1 KiB
JavaScript

const {execSync} = require('child_process');
const getWebhookSecret = () => {
const command = `stripe listen --print-secret ${process.env.CI ? `--api-key ${process.env.STRIPE_API_KEY}` : ''}`.trim();
const webhookSecret = execSync(command);
return webhookSecret.toString().trim();
};
/** @type {import('@playwright/test').PlaywrightTestConfig} */
const config = {
timeout: 60 * 1000,
workers: 1,
use: {
// Use a single browser since we can't simultaneously test multiple browsers
browserName: 'chromium',
headless: !process.env.PLAYWRIGHT_DEBUG,
baseURL: process.env.TEST_URL ?? 'http://localhost:2368',
// TODO: Where to put this
storageState: 'playwright-state.json'
},
globalSetup: './test/e2e-browser/utils/global-setup'
};
if (!process.env.TEST_URL) {
config.webServer = {
// TODO: Replace yarn start
command: 'yarn start',
env: {
NODE_ENV: 'development',
WEBHOOK_SECRET: getWebhookSecret()
},
reuseExistingServer: !process.env.CI,
url: 'http://localhost:2368'
};
}
module.exports = config;