mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-19 18:08:26 +00:00
test: run frontend unit tests in browsers (#38860)
Run them in headless [vitest browser mode](https://vitest.dev/guide/browser/) in chromium and firefox. Similar UX than current tests, it's about 5 times as slow (goes from 1s to 5s on my machine), but definitely worth it as it removes all happy-dom problems. --------- Signed-off-by: silverwind <me@silverwind.io>
This commit is contained in:
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
# playwright only supports ubuntu/debian officially, and on CI VMs its system deps are pre-installed
|
||||
if [ -z "${GITHUB_ACTIONS:-}" ] && [ "$(uname -s)" = "Linux" ] && grep -qE '^ID(_LIKE)?=.*(ubuntu|debian)' /etc/os-release 2>/dev/null; then
|
||||
pnpm exec playwright install --with-deps "$@"
|
||||
else
|
||||
pnpm exec playwright install "$@"
|
||||
fi
|
||||
+3
-25
@@ -44,13 +44,6 @@ wait_for_container() {
|
||||
echo "Container is ready."
|
||||
}
|
||||
|
||||
CMD="${1:-run}"
|
||||
if [ "$CMD" = "install" ] || [ "$CMD" = "run" ]; then
|
||||
[ $# -gt 0 ] && shift
|
||||
else
|
||||
CMD="run"
|
||||
fi
|
||||
|
||||
detect_playwright_mode
|
||||
|
||||
if [ "$PLAYWRIGHT_MODE" = "container" ]; then
|
||||
@@ -65,25 +58,10 @@ if [ "$PLAYWRIGHT_MODE" = "container" ]; then
|
||||
exit 1
|
||||
fi
|
||||
PLAYWRIGHT_IMAGE="mcr.microsoft.com/playwright:v${PLAYWRIGHT_VERSION}-noble"
|
||||
fi
|
||||
|
||||
if [ "$CMD" = "install" ]; then
|
||||
if [ "$PLAYWRIGHT_MODE" = "local" ]; then
|
||||
# on GitHub Actions VMs, playwright's system deps are pre-installed
|
||||
if [ -z "${GITHUB_ACTIONS:-}" ]; then
|
||||
# shellcheck disable=SC2086 # flag string
|
||||
pnpm exec playwright install --with-deps chromium firefox ${PLAYWRIGHT_FLAGS:-}
|
||||
else
|
||||
# shellcheck disable=SC2086 # flag string
|
||||
pnpm exec playwright install chromium firefox ${PLAYWRIGHT_FLAGS:-}
|
||||
fi
|
||||
else
|
||||
echo "Running playwright in container as host distro is not supported by playwright directly"
|
||||
if ! "$CONTAINER_RUNTIME" image inspect "$PLAYWRIGHT_IMAGE" >/dev/null 2>&1; then
|
||||
"$CONTAINER_RUNTIME" pull "$PLAYWRIGHT_IMAGE"
|
||||
fi
|
||||
echo "Running playwright in container"
|
||||
if ! "$CONTAINER_RUNTIME" image inspect "$PLAYWRIGHT_IMAGE" >/dev/null 2>&1; then
|
||||
"$CONTAINER_RUNTIME" pull "$PLAYWRIGHT_IMAGE"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Create isolated work directory
|
||||
|
||||
Reference in New Issue
Block a user