Skip to content

svelte-test

Frontend tests for a project's Svelte/JS UI:

  • vitestnpx vitest run (unit/component). Always-on (MR-gated + change-detected).
  • playwright — opt-in browser e2e (heavy — downloads browsers). Stays dormant behind enable_e2e: true + $RUN_E2E == "true", mirroring rust-test's cross-OS jobs, so it doesn't sit stuck-pending without an e2e setup. allow_failure: true.

Both run on dev-tools (Node 22) with the project-local tools (npm ci then npx), so the consumer carries vitest (+ test config) and, for e2e, @playwright/test. paths is required (no default).

Jobs

Job What it runs
vitest Per path: npm ci && $[[ inputs.test_command ]] (default npx vitest run).
playwright Per path: npm ci && npx playwright install --with-deps && $[[ inputs.e2e_command ]] (default npx playwright test). Only when enable_e2e: true and $RUN_E2E == "true".

Inputs

Input Type Default Description
image string dev-tools:v0.1.2 Image with Node + npm.
stage string test GitLab CI stage.
paths string (required) Space-separated frontend root(s).
if string '$CI_PIPELINE_SOURCE == "merge_request_event"' Gating rules:if: for vitest.
changes array ["**/*.svelte", "**/*.ts", "**/*.js", "**/*.css", "**/*.html", "**/package.json", "**/package-lock.json", "**/vite.config.*", "**/vitest.config.*", "**/svelte.config.*", "**/tsconfig*.json", ".gitlab-ci.yml"] Change-detection paths.
test_command string "npx vitest run" Command run in each root for unit/component tests.
enable_e2e boolean false Adds the playwright job.
e2e_command string "npx playwright test" Command run in each root for the e2e suite.

Usage

include:
  - component: gitlab.com/phpboyscout/cicd/[email protected]
    inputs:
      paths: "pkg/studio/web"
      test_command: "npx vitest run --passWithNoTests"

See also