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:

gameslib.dev.abstractplay.com

Local setup

  1. Build — from the gameslib repo root:

    npm run playground
    

    This builds APGames.min.js, copies locales/, and copies playground.* into dist/.

  2. Serve over HTTP — required (do not open playground.html via file://). Use WAMP/LAMP/nginx, or:

    npm run playground:serve
    

    Point your server at dist/ as the document root (or copy the contents of dist/ into your vhost).

  3. Openhttp://localhost:<port>/ or http://localhost:<port>/playground.html

  4. Rendererplayground.html loads APRender.min.js from 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:

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