Implements tests/PLAN.md § Playwright run (Section F's release
gate). 30 assertions in tests/verify-hooks-lib-foundry.mjs,
runs in ~10s against a live Foundry v14 instance.
What the Playwright test verifies that the no-Foundry smoke
test CAN'T:
- The library's init hook runs in Foundry's real lifecycle
(not a stubbed manual init call).
- mod.api is set on game.modules.get('foundry-hooks-lib') with
the documented surface.
- install() at init calls Hooks.on for every raw hook in the
registered set.
- A real Foundry-fired hook (combatStart, combatRound) delivers
an envelope to a consumer that subscribed AFTER init.
- A synthetic Hooks.callAll fire delivers envelopes to
subscribers (sync-mode hooks via direct dispatch,
async-mode hooks via microtask).
- subscribeAll receives envelopes from every registered hook.
- subscribe with an unknown hook name throws TypeError.
- A throwing consumer does NOT break the dispatch chain; the
second subscriber still fires; the error is logged via
console.error with the [foundry-hooks-lib] prefix.
- subscribe + unsubscribe correctly gate delivery.
**Bumps package.json to 0.3.0** (was 0.2.0 — version lagged
behind module.json's 0.3.0 from the rename commit).
**Adds test:foundry and test:all npm scripts.**
**Marks tests/PLAN.md status as Implemented** (was Proposed).
The Definition of done gate (npm run test:foundry exits 0 in
<30s) is now met.
**Adds playwright-core as a devDependency** (1 package, ~no
runtime impact since this repo's module doesn't depend on it at
runtime — it's a test-only dep).
**Final tallies:**
- npm test: 554/554 in ~0.4s (no-Foundry smoke)
- npm run test:foundry: 30/30 in ~10s (Playwright)
- npm run test:perf: 6/6 in ~5s (median 0.0003ms/fire)
- npm run test:all: all of the above
25 lines
964 B
JSON
25 lines
964 B
JSON
{
|
|
"name": "foundry-hooks-lib",
|
|
"version": "0.3.0",
|
|
"private": true,
|
|
"description": "Foundry VTT module: generic Foundry hook facade. Library-only — no UI, no settings, no domain interpretation. v0.2.0 implements HOOK_CONTRACT.md and tests/PLAN.md.",
|
|
"main": "scripts/main.js",
|
|
"type": "module",
|
|
"scripts": {
|
|
"test": "node tests/verify-hooks-lib.mjs",
|
|
"test:foundry": "node tests/verify-hooks-lib-foundry.mjs",
|
|
"test:perf": "node --expose-gc tests/perf.mjs",
|
|
"test:all": "node tests/verify-hooks-lib.mjs && node tests/verify-hooks-lib-foundry.mjs && node --expose-gc tests/perf.mjs",
|
|
"test:verbose": "TEST_VERBOSE=1 node tests/verify-hooks-lib.mjs"
|
|
},
|
|
"engines": {
|
|
"node": ">=18"
|
|
},
|
|
"author": "kaykayyali",
|
|
"license": "UNLICENSED",
|
|
"comment": "This package.json is for test/CI tooling only — Foundry VTT modules are loaded by Foundry, not by npm.",
|
|
"devDependencies": {
|
|
"playwright-core": "^1.61.0"
|
|
}
|
|
}
|