provide tests and CI to the project#35
Merged
Merged
Conversation
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
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.jsexercisesUtils.string2Uint8Data,fetchRemoteData, andfetchRemoteDataBlob.fetchis stubbed viavi.fnso no network is touched.tests/unit/arfset.test.jsexercises theARFsetconstructor: option defaults, partial overrides, initial field values, and the version banner. The emscripten wasm wrapper is mocked at import time so importingsrc/ARFset.jsstays cheap in Node.Playwright — end-to-end smoke
tests/e2e/marker-load.spec.jsboots a Chromium againstexample/example_es6.html, waits for the canvas to be populated bydisplay(), asserts the canvas has non-empty pixel content, and fails on any console error. This exercises the full wasm → JS → canvas path.Scripts
CI
.github/workflows/ci.ymlruns two parallel jobs on every push todev/masterand on every PR:npm ci+vitest run. No emsdk, no wasm.mymindstorm/setup-emsdk@v14(cached), builds wasm (npm run build), builds JS bundles (npm run build-es6), installs Chromium, runs Playwright. Uploadsplaywright-report/as an artifact on failure for triage.concurrency.cancel-in-progressaborts 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/testhttp-server(needed for Playwright'swebServerblock)Hygiene
Added
test-results/,playwright-report/,playwright/.cache/, andcoverage/to.gitignoreso per-run report directories don't get tracked.Test plan
npm testis green locallynpm run test:e2eis green locally (afternpm run build && npm run build-es6)Closes
Closes #28
Closes #29
Refs #31