Make testing more reliable

- Stop any running containers
- Start dev server from playwright so that we don't keep spawning new
  node instances
This commit is contained in:
RMidhunSuresh 2022-10-25 17:02:17 +05:30
parent 3ee26e14d7
commit 097d2296e0
No known key found for this signature in database
5 changed files with 36 additions and 13 deletions

View File

@ -19,7 +19,7 @@
"build": "vite build && ./scripts/cleanup.sh",
"build:sdk": "./scripts/sdk/build.sh",
"watch:sdk": "./scripts/sdk/build.sh && yarn run vite build -c vite.sdk-lib-config.js --watch",
"test:app": "vite --port 3000 & playwright test"
"test:app": "./scripts/test-app.sh"
},
"repository": {
"type": "git",

View File

@ -1,16 +1,20 @@
import type { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from "@playwright/test";
const BASE_URL = process.env["BASE_URL"] ?? "http://127.0.0.1:3000";
const config: PlaywrightTestConfig = {
use: {
headless: false,
viewport: { width: 1280, height: 720 },
ignoreHTTPSErrors: true,
video: 'on-first-retry',
baseURL: BASE_URL,
},
testDir: "./playwright/tests",
globalSetup: require.resolve("./playwright/global-setup"),
use: {
headless: false,
viewport: { width: 1280, height: 720 },
ignoreHTTPSErrors: true,
video: "on-first-retry",
baseURL: BASE_URL,
},
testDir: "./playwright/tests",
globalSetup: require.resolve("./playwright/global-setup"),
webServer: {
command: "yarn start",
url: `${BASE_URL}/#/login`,
},
};
export default config;

View File

@ -77,7 +77,7 @@ export async function dexStart(): Promise<DexInstance> {
console.log(`Starting dex with config dir ${dexCfg.configDir}...`);
const dexId = await dockerRun({
image: "bitnami/dex:latest",
containerName: "dex",
containerName: "hydrogen-dex",
dockerParams: [
"--rm",
"-v", `${dexCfg.configDir}:/data`,

View File

@ -108,7 +108,7 @@ export async function synapseStart(template: string): Promise<SynapseInstance> {
await dockerCreateNetwork({ networkName: "hydrogen" });
const synapseId = await dockerRun({
image: "matrixdotorg/synapse:develop",
containerName: `react-sdk-cypress-synapse-${crypto.randomBytes(4).toString("hex")}`,
containerName: `hydrogen-synapse`,
dockerParams: [
"--rm",
"-v", `${synCfg.configDir}:/data`,

19
scripts/test-app.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
# Make sure docker is available
if ! docker info > /dev/null 2>&1; then
echo "You need to intall docker before you can run the tests!"
exit 1
fi
# Stop running containers
if docker stop hydrogen-synapse > /dev/null 2>&1; then
echo "Existing 'hydrogen-synapse' container stopped ✔"
fi
if docker stop hydrogen-dex > /dev/null 2>&1; then
echo "Existing 'hydrogen-dex' container stopped ✔"
fi
# Run playwright
yarn playwright test