From 1fbb95da2b3018e8bc6f74afc166bd5199b444ea Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Fri, 17 Oct 2025 22:07:01 +0800 Subject: [PATCH] improve test scripts (#6016) 1. don't run browser tests in `headless` mode by default when running tests individually. because when writing/running tests, i usually want to see/debug using the browser. if one still wants headless, it's as easy as: `yarn workspace @uppy/xyz test --browser.headless`. instead append the `headless` mode when running all tests together - it doesn't make sense to run all projects' tests without headless mode. 2. don't always run browser tests with `watch`: watch doesn't make sense when running multiple projects in turbo (one project just blocks the rest watching for changes). if one still wants to run a single test with watch mode, it's as easy as: `yarn workspace @uppy/xyz test --watch` 3. don't cache test runs: if I run the `test` command. most of the time I want to actually run tests (not skip them if they already ran last time) 4. output logs when running tests. it's nice to see that the tests have actually run (also on CI) 5. when running all tests, use concurrency=1, because the tests also includes e2e tests, running multiple browsers in parallel really just makes the test fail on my computer (and uses a lot of memory) current output is not very informative: Screenshot 2025-10-17 at 17 09 55 with this PR: Screenshot 2025-10-17 at 17 20 49 --- examples/react/package.json | 2 +- examples/sveltekit/package.json | 2 +- examples/vue/package.json | 2 +- package.json | 3 ++- packages/@uppy/dashboard/package.json | 2 +- packages/@uppy/dashboard/vitest.config.ts | 1 - packages/@uppy/url/package.json | 2 +- packages/@uppy/url/vitest.config.ts | 1 - turbo.json | 8 ++++++-- 9 files changed, 13 insertions(+), 10 deletions(-) diff --git a/examples/react/package.json b/examples/react/package.json index 1695b0fb3..fded1f42e 100644 --- a/examples/react/package.json +++ b/examples/react/package.json @@ -4,7 +4,7 @@ "type": "module", "scripts": { "build": "tsc && vite build", - "test": "vitest run --browser.headless", + "test": "vitest run", "dev": "vite", "serve": "vite preview" }, diff --git a/examples/sveltekit/package.json b/examples/sveltekit/package.json index e7d31713d..c0a53a7c6 100644 --- a/examples/sveltekit/package.json +++ b/examples/sveltekit/package.json @@ -6,7 +6,7 @@ "scripts": { "dev": "vite dev", "build": "vite build", - "test": "vitest run --browser.headless", + "test": "vitest run", "preview": "vite preview", "prepare": "svelte-kit sync || echo ''", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", diff --git a/examples/vue/package.json b/examples/vue/package.json index 14d9ed084..6f7efff43 100644 --- a/examples/vue/package.json +++ b/examples/vue/package.json @@ -6,7 +6,7 @@ "scripts": { "dev": "vite", "build": "vite build", - "test": "vitest run --browser.headless", + "test": "vitest run", "preview": "vite preview --port 5050" }, "dependencies": { diff --git a/package.json b/package.json index 784c312bf..021d4cde2 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,8 @@ "dev": "yarn workspace @uppy-dev/dev dev", "dev:with-companion": "npm-run-all --parallel start:companion dev", "start:companion": "yarn workspace @uppy/companion start:dev", - "test": "turbo run test --filter='./packages/@uppy/*' --filter='./packages/uppy' --filter='./examples/{react,vue,sveltekit}'", + "test": "turbo run test --concurrency=1 --filter='./packages/@uppy/*' --filter='./packages/uppy' --filter='./examples/{react,vue,sveltekit}' -- --browser.headless", + "test:e2e": "turbo run test:e2e --concurrency=1 --filter='./packages/@uppy/*' --filter='./packages/uppy' --filter='./examples/{react,vue,sveltekit}' -- --browser.headless", "test:watch": "turbo watch test --filter='./packages/@uppy/*' --filter='./packages/uppy'", "typecheck": "turbo run typecheck --filter='./packages/@uppy/*' --filter='./packages/uppy'", "version": "changeset version && corepack yarn install --mode=update-lockfile && node scripts/update-readme-versions.mjs", diff --git a/packages/@uppy/dashboard/package.json b/packages/@uppy/dashboard/package.json index f548e871f..e5698454f 100644 --- a/packages/@uppy/dashboard/package.json +++ b/packages/@uppy/dashboard/package.json @@ -13,7 +13,7 @@ "build:css": "sass --load-path=../../ src/style.scss dist/style.css && postcss dist/style.css -u cssnano -o dist/style.min.css", "typecheck": "tsc --build", "test": "vitest run --silent='passed-only'", - "test:e2e": "vitest watch --project browser --browser.headless false" + "test:e2e": "vitest run --project browser" }, "keywords": [ "file uploader", diff --git a/packages/@uppy/dashboard/vitest.config.ts b/packages/@uppy/dashboard/vitest.config.ts index ae4a20490..b316316fc 100644 --- a/packages/@uppy/dashboard/vitest.config.ts +++ b/packages/@uppy/dashboard/vitest.config.ts @@ -19,7 +19,6 @@ export default defineConfig({ include: ['src/**/*.browser.test.{ts,tsx}'], browser: { enabled: true, - headless: true, provider: 'playwright', instances: [{ browser: 'chromium' }], }, diff --git a/packages/@uppy/url/package.json b/packages/@uppy/url/package.json index 1bc7b2375..ebf9822aa 100644 --- a/packages/@uppy/url/package.json +++ b/packages/@uppy/url/package.json @@ -13,7 +13,7 @@ "build:css": "sass --load-path=../../ src/style.scss dist/style.css && postcss dist/style.css -u cssnano -o dist/style.min.css", "typecheck": "tsc --build", "test": "vitest run --silent='passed-only'", - "test:e2e": "vitest watch --project browser --browser.headless false" + "test:e2e": "vitest run --project browser" }, "keywords": [ "file uploader", diff --git a/packages/@uppy/url/vitest.config.ts b/packages/@uppy/url/vitest.config.ts index efcb29ca4..08eeefd25 100644 --- a/packages/@uppy/url/vitest.config.ts +++ b/packages/@uppy/url/vitest.config.ts @@ -10,7 +10,6 @@ export default defineConfig({ globalSetup: './vitest.setup.ts', browser: { enabled: true, - headless: true, provider: 'playwright', instances: [{ browser: 'chromium' }], }, diff --git a/turbo.json b/turbo.json index 8b4eab539..0fec0fb4f 100644 --- a/turbo.json +++ b/turbo.json @@ -34,8 +34,12 @@ "inputs": ["src/**/*.{js,ts,jsx,tsx}", "tsconfig.json"] }, "test": { - "outputLogs": "errors-only", - "dependsOn": ["^test"] + "dependsOn": ["^test"], + "cache": false + }, + "test:e2e": { + "dependsOn": ["^test:e2e"], + "cache": false } } }