Skip to content

provide tests and CI to the project#35

Merged
kalwalt merged 4 commits into
devfrom
feat-test-improves
Jun 3, 2026
Merged

provide tests and CI to the project#35
kalwalt merged 4 commits into
devfrom
feat-test-improves

Conversation

@kalwalt
Copy link
Copy Markdown
Member

@kalwalt kalwalt commented Jun 3, 2026

Summary

Add the test surface for the project and gate it in CI. Two complementary layers + a GitHub Actions workflow that runs them on every PR.

Vitest — fast unit tests, no wasm

  • tests/unit/utils.test.js exercises Utils.string2Uint8Data, fetchRemoteData, and fetchRemoteDataBlob. fetch is stubbed via vi.fn so no network is touched.
  • tests/unit/arfset.test.js exercises the ARFset constructor: option defaults, partial overrides, initial field values, and the version banner. The emscripten wasm wrapper is mocked at import time so importing src/ARFset.js stays cheap in Node.

Playwright — end-to-end smoke

  • tests/e2e/marker-load.spec.js boots a Chromium against example/example_es6.html, waits for the canvas to be populated by display(), asserts the canvas has non-empty pixel content, and fails on any console error. This exercises the full wasm → JS → canvas path.

Scripts

npm test                  -> vitest run
npm run test:watch        -> vitest in watch mode
npm run test:e2e          -> playwright test
npm run test:e2e:install  -> playwright install --with-deps chromium  (one-shot per machine)

CI

.github/workflows/ci.yml runs two parallel jobs on every push to dev/master and on every PR:

  • unit: fast. npm ci + vitest run. No emsdk, no wasm.
  • build-and-e2e: clones submodules, sets up emsdk via mymindstorm/setup-emsdk@v14 (cached), builds wasm (npm run build), builds JS bundles (npm run build-es6), installs Chromium, runs Playwright. Uploads playwright-report/ as an artifact on failure for triage.

concurrency.cancel-in-progress aborts superseded runs on the same branch/PR so we don't queue duplicate work.

No auto-publish on tag in this PR — release is still a manual npm publish. We can add that as a follow-up once the workflow has shown it's stable.

devDependencies added

  • vitest
  • @playwright/test
  • http-server (needed for Playwright's webServer block)

Hygiene

Added test-results/, playwright-report/, playwright/.cache/, and coverage/ to .gitignore so per-run report directories don't get tracked.

Test plan

  • npm test is green locally
  • npm run test:e2e is green locally (after npm run build && npm run build-es6)
  • First CI run on this PR is green for both jobs

Closes

Closes #28
Closes #29

Refs #31

claude and others added 3 commits June 3, 2026 22:27
Two complementary layers:

Vitest covers the pure JS paths that don't need wasm:
- Utils.string2Uint8Data, fetchRemoteData, fetchRemoteDataBlob
  (fetch is stubbed via vi.fn so no network is touched)
- ARFset constructor (option handling, defaults, initial fields,
  version banner) with the wasm wrapper mocked out so importing
  src/ARFset.js stays cheap

Playwright drives a real Chromium against example_es6.html, waits
for the canvas to be populated by display(), and asserts the canvas
has non-empty pixel content. This exercises the full wasm -> JS ->
canvas path end to end.

Scripts:
  npm test                 -> vitest run
  npm run test:watch       -> vitest in watch mode
  npm run test:e2e:install -> playwright install --with-deps chromium
                              (one-shot per machine)
  npm run test:e2e         -> playwright test

devDependencies added: vitest, @playwright/test, http-server
(needed for Playwright's webServer block).

Refs #28
Refs #31
Two jobs that run on every PR and on pushes to dev/master:

- unit (fast): npm ci + vitest. No emsdk, no wasm.
- build-and-e2e: clones submodules, sets up emsdk via
  mymindstorm/setup-emsdk@v14 (cached), builds wasm
  (npm run build), builds JS bundles (npm run build-es6),
  installs Chromium, runs Playwright. Uploads the
  playwright-report/ directory on failure for triage.

concurrency.cancel-in-progress lets a new push to the same PR
abort the previous run automatically.

No auto-publish on tag yet; release is still a manual npm publish.

Refs #29
Refs #31
- exclude test artifacts files from git
@kalwalt kalwalt self-assigned this Jun 3, 2026
@kalwalt kalwalt added enhancement New feature or request C/C++ about C and C++ code js code dependencies Pull requests that update a dependency file javascript Pull requests that update javascript code labels Jun 3, 2026
…specs

Vitest discovers any *.test.js / *.spec.js by default and tried to
import tests/e2e/marker-load.spec.js, where @playwright/test's test()
errors out because it's invoked outside the Playwright runner.
@kalwalt kalwalt merged commit b5cef7f into dev Jun 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C/C++ about C and C++ code dependencies Pull requests that update a dependency file enhancement New feature or request javascript Pull requests that update javascript code js code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants