-
-
Notifications
You must be signed in to change notification settings - Fork 383
Configure Vitest for unit and browser tests (use @puppeteer/browsers and webdriverio) #3010
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Browser Tests | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
on: | ||
push: | ||
paths-ignore: | ||
- 'src/*/doc/**' | ||
- 'src/**/*.md' | ||
- 'ux.symfony.com/**' | ||
- '.github/workflows/app-tests.yaml' | ||
- '.github/workflows/unit-tests.yaml' | ||
pull_request: | ||
paths-ignore: | ||
- 'src/*/doc/**' | ||
- 'src/**/*.md' | ||
- 'ux.symfony.com/**' | ||
- '.github/workflows/app-tests.yaml' | ||
- '.github/workflows/unit-tests.yaml' | ||
|
||
jobs: | ||
js: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: npm i -g corepack && corepack enable | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: '.nvmrc' | ||
cache: 'pnpm' | ||
cache-dependency-path: | | ||
pnpm-lock.yaml | ||
package.json | ||
src/**/package.json | ||
- run: pnpm install --frozen-lockfile | ||
|
||
- name: Install browsers | ||
run: node ./bin/get_browsers.mjs | ||
|
||
# TODO: Install the E2E app + run webserver | ||
- run: pnpm run test:browser |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# Deprecated, will be removed in favor of browser-tests.yml | ||
name: Functional Tests | ||
|
||
defaults: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
vendor/ | ||
node_modules | ||
|
||
.doctor-rst.cache | ||
|
@@ -7,3 +6,5 @@ node_modules | |
|
||
/composer.lock | ||
/vendor | ||
|
||
/browsers |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
22.11 | ||
22.18 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I can use |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import * as path from 'node:path'; | ||
import { | ||
Browser, | ||
BrowserTag, | ||
detectBrowserPlatform, | ||
install as installBrowser, | ||
resolveBuildId, | ||
} from '@puppeteer/browsers'; | ||
|
||
const platform = detectBrowserPlatform(); | ||
const installBrowserCommonOpts = { | ||
platform, | ||
cacheDir: path.join(import.meta.dirname, '../browsers'), | ||
downloadProgressCallback: 'default', | ||
}; | ||
|
||
// Lowest versions are computed from "defaults and fully supports es6-module" query, | ||
// see https://browsersl.ist/#q=defaults+and+fully+supports+es6-module | ||
|
||
export const browsers = { | ||
'chrome@lowest': await installBrowser({ | ||
...installBrowserCommonOpts, | ||
browser: Browser.CHROME, | ||
// The lowest version where: | ||
// - Chrome and associated Chromedriver could easily be downloaded | ||
// - there is no compatibility issues like "WebDriver Bidi command \"session.subscribe\" failed with error" | ||
// - there is no timeout issues when requesting Vitest webserver | ||
// @see https://raw.githubusercontent.com/GoogleChromeLabs/chrome-for-testing/refs/heads/main/data/known-good-versions-with-downloads.json | ||
buildId: '130.0.6669.0', | ||
}), | ||
'chrome@latest': await installBrowser({ | ||
...installBrowserCommonOpts, | ||
browser: Browser.CHROME, | ||
buildId: await resolveBuildId(Browser.CHROME, platform, BrowserTag.STABLE), | ||
}), | ||
'firefox@lowest': await installBrowser({ | ||
...installBrowserCommonOpts, | ||
browser: Browser.FIREFOX, | ||
buildId: 'stable_128.0', | ||
}), | ||
'firefox@latest': await installBrowser({ | ||
...installBrowserCommonOpts, | ||
browser: Browser.FIREFOX, | ||
buildId: await resolveBuildId(Browser.FIREFOX, platform, BrowserTag.STABLE), | ||
}), | ||
}; | ||
|
||
if (import.meta.main) { | ||
console.log('Browsers installed:', browsers); | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the future, it would be nice to shift the 1st argument (package location) and pass all the other arsg to |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,31 @@ | ||
{ | ||
"private": true, | ||
"packageManager": "pnpm@10.13.1+sha512.37ebf1a5c7a30d5fabe0c5df44ee8da4c965ca0c5af3dbab28c3a1681b70a256218d05c81c9c0dcf767ef6b8551eb5b960042b9ed4300c59242336377e01cfad", | ||
"packageManager": "pnpm@10.14.0+sha512.ad27a79641b49c3e481a16a805baa71817a04bbe06a38d17e60e2eaee83f6a146c6a688125f5792e48dd5ba30e7da52a5cda4c3992b9ccf333f9ce223af84748", | ||
"type": "module", | ||
"workspaces": [ | ||
"src/*/assets", | ||
"src/*/src/Bridge/*/assets" | ||
], | ||
"scripts": { | ||
"build": "pnpm run --filter @symfony/ux-map build && pnpm run -r --aggregate-output build", | ||
"test": "pnpm run -r --aggregate-output test", | ||
"test": "pnpm run -r --workspace-concurrency=1 test", | ||
"test:unit": "pnpm run -r --aggregate-output test:unit", | ||
"test:browser": "pnpm run -r --workspace-concurrency=1 test:browser", | ||
"check": "biome check", | ||
"ci": "biome ci" | ||
}, | ||
"devDependencies": { | ||
"@biomejs/biome": "^2.0.4", | ||
"@puppeteer/browsers": "^2.10.6", | ||
"@testing-library/dom": "^10.4.0", | ||
"@testing-library/jest-dom": "^6.6.3", | ||
"@types/node": "^22.6.0", | ||
"lightningcss": "^1.28.2", | ||
"pkg-types": "^2.2.0", | ||
"playwright": "^1.47.0", | ||
"tinyglobby": "^0.2.14", | ||
"tsup": "^8.5.0", | ||
"vitest": "^3.2.4" | ||
"vitest": "^3.2.4", | ||
"webdriverio": "^9.19.1" | ||
}, | ||
"version": "2.27.0" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to unit tests in multiple Node.js versions, our
assets/
code is supposed to run in a browser. We are testing the strict necessary