Writing Tests
In Plugwright, every test runs with a pre-configured context. You usetest() to define a scenario and expect() to make assertions.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Understand the fundamentals of Plugwright.
test() to define a scenario and expect() to make assertions.
import { expect, test } from '@plugwright/runner';
test('Basic test', async ({ player }) => {
// Your test logic here
});
test('Click an item in GUI', async ({ player }) => {
player.chat('/openmenu');
// Wait for the GUI to open and get a live handle
const gui = await player.gui({ title: 'Menu' });
// Find an item by its internal name or display name
const shopItem = gui.locator(i => i.displayName.includes('Shop'));
await shopItem.click();
await expect(player).toHaveReceivedMessage('You opened the shop!');
});
test('Players can trade', async ({ player, createPlayer }) => {
const friend = await createPlayer({ username: 'TraderBot' });
player.chat(`/pay ${friend.username} 100`);
await expect(friend).toHaveReceivedMessage('You received 100 coins!');
});