Tests
Unit tests#
Tests are tests/*.test.ts (and any src/**/*.test.ts), run by vitest in Node with no
browser. The whole suite takes a few seconds.
The suites open two sets of map files:
tests/maps/is committed: five small.scxand.scmmaps built bytests/support/testMaps.tsfrom the editor's own code, with nothing of Blizzard's in them. They cover the four file revisions, the three archive compressions, an archive without a file list, triggers, a briefing, locations, a sound and unit settings, but no terrain.tests/maps.test.tsfails when the files and the code that makes them disagree: runnpm run test:mapsand commit the result. Only generated maps go here.fixtures/maps/holds Blizzard's own maps, on a machine that has them. The suites about terrain, doodads and what StarEdit itself writes need these, the extracted data inpublic/, or both, and skip when the files are absent. CI has neither, so a green CI run has not exercised them; the CI run's Summary page on GitHub lists every suite that skipped, by name. Run them locally before touching a tileset decoder, the doodad code, the isometric brush or anything undersrc/formats/.
Two suites are worth knowing about:
tests/plugin-network.test.tsfetches, transpiles and imports the real default plugins from GitHub. It runs only withSCMJS_NETWORK_TESTS=1; CI runs it in the web build and the release pre-flight.tests/docs.test.tschecks these documents: the split into site pages, every relative link and picture, the 90-column wrap, and that the plugin guide names only calls the API declares.
Browser tests#
e2e/*.spec.ts are Playwright specs that drive the built editor in headless Chromium.
They cover what the unit tests cannot: that the bundle starts, that each dialog's chunk
loads and mounts, and that a change made through the chrome ends up in the saved file.
npx playwright install chromium # once
npm run build # the specs run against dist/
npm run test:e2e
npx playwright test e2e/save.spec.ts # one file
npx playwright test --ui # watch a spec run, step through it
npm run test:e2e serves dist/ with vite preview on port 4173 and does not build, so
build again after changing the editor. To run against something already being served, the
dev server included, set SCMJS_E2E_URL to its address.
Every spec runs under the same conditions, set up in e2e/support/editor.ts, so a run on
a machine with game data is the run CI makes:
- No game data. Terrain is flat colours, and the editor offers Help ▸ Game Data… soon after it starts; a spec that uses the chrome closes that first.
- No network. Anything not served by the build under test is refused.
- No native file pickers. The editor opens through a file input and saves as a download, as in Firefox and Safari.
A test also fails if the page threw or logged an error.
| Spec | Checks |
|---|---|
boot.spec.ts |
A first visit: splash, editor, the Game Data offer, a blank map drawn |
dialogs.spec.ts |
Every dialog opens, in English and Korean |
save.spec.ts |
A map renamed and saved; every other section comes back byte for byte |
errors.spec.ts |
A dialog whose chunk fails closes with a notice; the editor carries on |
dataPage.spec.ts |
The Game Data page on its own |
installPage.spec.ts |
The page that installs game data for another page of the site |
moveIn.spec.ts |
Settings kept at the old address are brought over on the first visit |
pluginUpdates.spec.ts |
Checking all plugins for updates, and Update all |
docks.spec.ts |
Dragging a dock's edge over a plugin's map view |
rulers.spec.ts |
The rulers line up with the map past the scrollbars |
dialogs.spec.ts reads the dialog ids from the registry, so a new dialog is covered
without touching the spec; one that renders nothing without a payload must be added to its
NEEDS_PAYLOAD list. A failure leaves a trace under test-results/;
npx playwright show-trace <trace.zip> replays it. CI runs the specs in the web build and
keeps the report of a failed run.