Testing
Unit tests
npm test
Game-specific tests live in test/games/. Good unit tests will save future you (and future maintainers) a lot of headaches. No need to test basic stuff tested elsewhere (like graph/grid functions), but it's wise to test end-of-game resolution and any edge cases. See existing tests for patterns.
CLI example
bin/example.ts — run moves from the command line:
npx ts-node bin/example.ts <uid> [moves...]
Browser playground
The standalone gameslib playground is not part of the docs site:
Local setup
-
Build — from the gameslib repo root:
npm run playgroundThis builds
APGames.min.js, copieslocales/, and copiesplayground.*intodist/. -
Serve over HTTP — required (do not open
playground.htmlviafile://). Use WAMP/LAMP/nginx, or:npm run playground:servePoint your server at
dist/as the document root (or copy the contents ofdist/into your vhost). -
Open —
http://localhost:<port>/orhttp://localhost:<port>/playground.html -
Renderer —
playground.htmlloadsAPRender.min.jsfrom the dev CDN by default. Only build or copy a local renderer bundle if you are working on renderer.
Translations
Game descriptions, variant names, and other strings are loaded at runtime from ./locales/{lang}/{ns}.json beside playground.html. npm run playground copies these into dist/locales/.
If descriptions show raw keys like apgames:descriptions.complica:
- Confirm
dist/locales/en/apgames.jsonexists. - Confirm you are serving over HTTP, not
file://. - Do not serve only
playground/withoutlocales/— serve the fulldist/output.
The browser console will warn if locale bundles failed to load.
Troubleshooting (WAMP / subfolder hosting)
If you serve from a subdirectory (e.g. http://localhost/myproject/playground.html), locale files must still sit beside playground.html in that folder (myproject/locales/...). The relative load path resolves from the page URL, not the server document root — so copying the full dist/ contents into your vhost subfolder is the simplest approach.
Renderer output
Prototype board JSON at renderer.dev.abstractplay.com before wiring render() in your game.
Example games
- Complica tests — grep
complicaundertest/games/