Appearance
Unit Tests API
The unit tests are based on Vitest, please read the guide to install and run the tests.
Testing API
Summary
Clear
- Method:
clear()
- Return:
void
- Usage:
Clear caches. Use it after the end of each test
ts
import { clear } from '@rpgjs/testing'
import { afterEach } from 'vitest'
afterEach(() => {
clear()
})
Next Tick
- Method:
nextTick(client,timestamp?)
- Arguments:
- {
RpgClientEngine
}client
. (Optional:false
) - {
number
}timestamp
. A predefined timestamp (Optional:true
)
- {
- Return:
Promise
- Usage:
Allows you to make a tick:
- on server
- server sends data to client
- Client retrieves data and performs inputs (move, etc.) and server reconciliation
- A tick is performed on the client
- A tick is performed on VueJS
Wait a moment
- Since: 4.0.0
- Method:
waitUntil(promise)
- Arguments:
- {
Promise
}promise
. (Optional:false
)
- {
- Return:
Promise
- Example:
ts
await waitUntil(
player.moveRoutes([Move.right()])
)
- Usage:
Fixture API
Create Client
- Method:
createClient()
- Return:
Promise
- Usage:
Allows you to create a client and get fixtures to manipulate it during tests
Returns:
ts
{
client: RpgClientEngine,
socket: any,
playerId: string
player: RpgPlayer
}
Add Other Client In Map
- Since: 3.2.0
- Method:
addOtherClientInMap(firstClient,mapId,position?)
- Arguments:
- {
RpgClientEngine
}firstClient
. (Optional:false
) - {
string
}mapId
. (Optional:false
) - {
Position | string
}position
. (Optional:true
)
- {
- Return:
Promise
- Usage:
Create another client, add it to the map and send the information to the first client
server
- Property:
server
- Type:
RpgServerEngine
- Optional:
false
- Usage:
Get server
Change Map
- Method:
changeMap(client,mapId,position?)
- Arguments:
- {
RpgClientEngine
}client
. (Optional:false
) - {
string
}mapId
. (Optional:false
) - {
Position | string
}position
. (Optional:true
)
- {
- Return:
Promise
- Usage:
Allows you to change the map. This function on the tests also allows to render with PIXI on the client side