Skip to content

test(e2e): Show test progress & ensure we clean before running tests #8649

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"test:validate-test-app-setups": "ts-node validate-test-app-setups.ts",
"test:prepare": "ts-node prepare.ts",
"test:validate": "run-s test:validate-configuration test:validate-test-app-setups",
"clean": "rimraf tmp test-applications/**/{node_modules,dist,build,.next,.sveltekit,pnpm-lock.yaml}"
"clean": "rimraf tmp node_modules && yarn clean:test-applications",
"clean:test-applications": "rimraf test-applications/**/{node_modules,dist,build,.next,.sveltekit,pnpm-lock.yaml}"
},
"devDependencies": {
"@types/glob": "8.0.0",
Expand Down
33 changes: 30 additions & 3 deletions packages/e2e-tests/run.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,37 @@
/* eslint-disable max-lines */
/* eslint-disable no-console */
import { exec } from 'child_process';
import { spawn } from 'child_process';
import * as dotenv from 'dotenv';
import { sync as globSync } from 'glob';
import { resolve } from 'path';
import { promisify } from 'util';

import { validate } from './lib/validate';
import { registrySetup } from './registrySetup';

const asyncExec = promisify(exec);
function asyncExec(command: string, options: { env: Record<string, string | undefined>; cwd: string }): Promise<void> {
return new Promise((resolve, reject) => {
const process = spawn(command, { ...options, shell: true });

process.stdout.on('data', data => {
console.log(`${data}`);
});

process.stderr.on('data', data => {
console.error(`${data}`);
});

process.on('error', error => {
reject(error);
});

process.on('close', code => {
if (code !== 0) {
return reject();
}
resolve();
});
});
}

async function run(): Promise<void> {
// Load environment variables from .env file locally
Expand All @@ -31,8 +53,13 @@ async function run(): Promise<void> {
const env = { ...process.env, ...envVarsToInject };

try {
console.log('Cleaning test-applications...');
console.log('');

registrySetup();

await asyncExec('pnpm clean:test-applications', { env, cwd: __dirname });

const testAppPaths = appName ? [appName.trim()] : globSync('*', { cwd: `${__dirname}/test-applications/` });

console.log(`Runnings tests for: ${testAppPaths.join(', ')}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"scripts": {
"build": "next build",
"clean": "npx rimraf node_modules,pnpm-lock.yaml",
"test:prod": "TEST_ENV=prod playwright test",
"test:dev": "TEST_ENV=dev playwright test",
"test:build": "pnpm install && npx playwright install && pnpm build",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"clean": "npx rimraf node_modules,pnpm-lock.yaml",
"test:build": "pnpm install && pnpm build",
"test:build-ts3.8": "pnpm install && pnpm add [email protected] && pnpm build",
"test:build-canary": "pnpm install && pnpm add react@canary react-dom@canary && pnpm build",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"dev": "remix dev",
"start": "remix-serve build",
"typecheck": "tsc",
"clean": "npx rimraf node_modules,pnpm-lock.yaml",
"test:build": "pnpm install && npx playwright install && pnpm build",
"test:assert": "pnpm playwright test"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"scripts": {
"build": "next build > .tmp_build_output",
"clean": "npx rimraf node_modules,pnpm-lock.yaml",
"test:prod": "TEST_ENV=production playwright test",
"test:dev": "TEST_ENV=development playwright test",
"test:build": "pnpm install && npx playwright install && pnpm build",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"build": "tsc",
"start": "node dist/app.js",
"test": "playwright test",
"clean": "npx rimraf node_modules,pnpm-lock.yaml",
"test:build": "pnpm install && pnpm build",
"test:assert": "pnpm test"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"build": "react-scripts build",
"start": "serve -s build",
"test": "playwright test",
"clean": "npx rimraf node_modules,pnpm-lock.yaml",
"test:build": "pnpm install && npx playwright install && pnpm build",
"test:build-canary": "pnpm install && pnpm add react@canary react-dom@canary && npx playwright install && pnpm build",
"test:assert": "pnpm test"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"build": "react-scripts build",
"start": "serve -s build",
"test": "playwright test",
"clean": "npx rimraf node_modules,pnpm-lock.yaml",
"test:build": "pnpm install && npx playwright install && pnpm build",
"test:assert": "pnpm test"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"build": "react-scripts build",
"start": "serve -s build",
"test": "playwright test",
"clean": "npx rimraf node_modules,pnpm-lock.yaml",
"test:build": "pnpm install && npx playwright install && pnpm build",
"test:build-ts3.8": "pnpm install && pnpm add [email protected] && npx playwright install && pnpm build",
"test:build-canary": "pnpm install && pnpm add react@canary react-dom@canary && npx playwright install && pnpm build",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"clean": "npx rimraf node_modules,pnpm-lock.yaml",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"test:prod": "TEST_ENV=production playwright test",
Expand Down