@v12-engine/client/testing
Interfaces
| Name | What |
|---|---|
| CinematicRun beta | A cinematic played in a test (stepCinematic): what happened, and the means to go on |
| ScriptedSession beta | A session that plays the snapshots it is given, one each update, for a test of what the screen makes of them: the first is snapshot(), what a snapshot leaves out is empty (tick its place in the list), and the commands sent are kept (sent) and answered with their number. The map is flat (terrain, 64 by 64 cells where not given) and the game's data is registry (empty where not given); the rest of the session as the test gives it ts // scriptedSession, of `@v12-engine/client/testing` const session = scriptedSession([{ entities: [] }, { entities: [soldier] }], { registry: world.registry }) state.apply(session.snapshot()) for (const snapshot of session.update(0.1)) state.apply(snapshot) |
| StageCall beta | Something a cinematic did to the stage: what (camera, say, clip, send, screen, picture, music...), with what, at what time of the cinematic's clock |
| StepOptions beta | How stepCinematic plays: on a stage of its own (testStage with units and the rest) or one handed in, so many seconds in frames of dt, with what the game would hand it (params), its hooks, and the options of the play (hold, skippable...). entries are the view's cinematics by id, for one played by id or included by another |
| TestHandles beta | What a page shows its browser tests (window.__v12, with ?test in the page's address): the game on it, and whatever else the page shows them by name (the editor's: EditorTestHandles of @v12-engine/editor/testing). Each is there while it is on the page |
| TestHudClient beta | What a test of a HUD part gets: the client the part reads, and what the player's hands were asked to do |
| TestStage beta | A stage of plain data (testStage): a Stage that writes down what is done to it, and what is on it now |
| TestStageOptions beta | How a test's stage is made: its units, the map's views and paths and regions by name, the lanes and eases of the game's, the camera's pose to begin with, and the player it plays as |
| TestUnit beta | A unit of a test's stage: what it is, whose, where, and the name the map gave it |
Functions
| Name | What |
|---|---|
| fake beta | A fake of T for a test: the members given (FakeOf), nothing else. What the code under test reads that is not given is undefined, as in a literal; the names and the arguments are checked against T's ts // fake, of `@v12-engine/client/testing` const ground = fake<Terrain>({ heightAt: () => 2 }) |
| fakeKit beta | The render kit (LiteRenderKit) for a test of a game's own renderer made of one, with no renderer: only the members the test gives (FakeOf), ring doing nothing where it gives none ts // fakeKit, of `@v12-engine/client/testing` const kit = fakeKit({ drawn: () => ({ x: 1, y: 0, z: 1, visible: true }) }) const shield = shieldRenderer(kit) |
| fakeStage beta | A stage for a test that needs a stage and a few members of its own: the plain-data one (testStage), with these members in place of its own |
| fixtureView beta | The view of fixtureGame() (of @v12-engine/engine/testing): a GameView with a plain look for each of its unit types, a box of the size the type's radius gives, tall for a building and a hero. For a test that needs a renderer or a HUD to have something to draw for the fixture's soldiers, buildings and trees, with no model to load. over is put over it (visuals merged by type, the rest replaced) ts // fixtureView, of `@v12-engine/client/testing` const view = fixtureView({ hud: { hide: ['clock'] } }) expect(view.units.visuals.soldier!.parts).toHaveLength(1) |
| scriptedSession beta | See ScriptedSession |
| stepCinematic beta | Plays a cinematic (a def or a script) as the game does, on a test's stage, for seconds (a 60th of a second a frame): see the top of this file |
| testClient beta | A client for a test of a part that is handed one (GameClientApi: a game's hook, a setting, a line of the pause menu, the hands, the minimap), with no page and no renderer: a real createUi() model, empty keys whose context it is, a log nobody reads, the page's storage, the given view (visuals empty when not given); the rest as the test gives it (FakeOf), and nothing where it gives none. More is what the part's host takes of GameClient besides (mapPings for the minimap) ts // testClient, of `@v12-engine/client/testing` const client = testClient({ camera: { edgePan: true }, sounds: { level: () => 1 } }) const settings = new Settings(client, undefined) |
| testHudClient beta | A HudClient for a test of a HUD part, with no page and no renderer: a real createUi() model, a real HudEvents told from it, empty keys, the given view (visuals left empty when not given), and hands (controller) that write down what they are asked to do (done) and answer nothing, and portraits with no models (the faces show their pictures). Whatever else a test needs of the client is passed in members, and replaces the stand-in ts // testHudClient, of `@v12-engine/client/testing` const client = testHudClient({ view: { hud: { hide: ['clock'] } } }) client.ui.setIdleWorkers(3) client.controller.selectIdleWorker() expect(client.done).toEqual([{ what: 'selectIdleWorker', args: [] }]) |
| testStage beta | A stage of plain data a cinematic plays on in a test: see TestStage |
Types
| Name | What |
|---|---|
| FakeOf beta | What a test gives a fake of T: any of its members, each as far as the test needs it. A function takes what T's takes, or less of it (a method's), and gives back what the test wants (a mesh of the two fields the code reads); an object is a fake of its own, or the real one. A name T does not have is an error, as is an argument of another type |
| GameTestHandle beta | What a browser test reaches of the game on its page (X9): the members the specs ask for, by name, so that a member renamed or made private in GameClient fails the build of the test handle, not a spec at runtime. The few parts the specs look inside that the client keeps to itself (the canvas, the minimap, the daylight...) are named here too: a test that reads them says so |