@vttforge/testing / container / FoundryContainer
Interface: FoundryContainer ​
A running Foundry. Call stop() when the run is over.
Properties ​
baseUrl ​
readonlybaseUrl:string
Absolute, because it is not always localhost.
network ​
readonlynetwork:string|null
The Docker network Foundry joined, or null when the port is published.
packages ​
readonlypackages:ReadonlyMap<string,FoundryManifest>
Manifests of everything installed, by package id.
system ​
readonlysystem:FoundryManifest
The manifest of the system that world runs on. Changes with switchWorld.
worldId ​
readonlyworldId:string
Id of the world Foundry is running. Changes with switchWorld.
Methods ​
createWorld() ​
createWorld(
world):void
Declare another world, on a system that is already installed.
Writing the manifest is all it takes for Foundry to know the world exists. Foundry runs one world at a time, so the new one is idle until switchWorld points at it.
foundry.createWorld({ id: 'second', title: 'Second world' });
await foundry.switchWorld('second');Parameters ​
world ​
Returns ​
void
install() ​
install(
source):FoundryManifest
Copy a built package into the container and hand back its manifest.
Foundry scans its packages directory once, at startup. A package installed into a running Foundry stays invisible until restart().
Parameters ​
source ​
Returns ​
logs() ​
logs(
tail?):string
The container's last log lines.
Parameters ​
tail? ​
number
Returns ​
string
restart() ​
restart():
Promise<void>
Stop and start, clearing the lock that a stop does not always clear.
Resolves once the world is joinable, not merely once the server answers. Those are two different moments, and a package installed between them is not loaded yet.
Returns ​
Promise<void>
stop() ​
stop():
void
Remove the container. The volume survives, so the next run starts faster.
Returns ​
void
switchWorld() ​
switchWorld(
id):Promise<void>
Launch a world that exists, and wait for it to be joinable.
Restarts Foundry, so every browser session on the old world is gone and a test driving one has to join again. World-scoped state does not carry over: a module enabled in one world is disabled in the next.
Switching to the world already running does nothing.
Parameters ​
id ​
string
Returns ​
Promise<void>