Writing Tests
Your first test
import { test, expect } from '@appetize/playwright'
// reinstall app after each test to reset data
test.afterEach(async ({ session }) => {
await session.reinstallApp()
})
test('logs in to the app', async ({ session }) => {
// type username
await session.tap({
element: {
attributes: {
accessibilityIdentifier: 'username_field'
}
}
})
await session.type('jordan')
// type password
await session.tap({
element: {
attributes: {
accessibilityIdentifier: 'password_field'
}
}
})
await session.type('secretpassword')
// tap login button
await session.tap({
element: {
attributes: {
text: 'Login'
}
}
})
// assert that an element with 'Hello Jordan' exists on the screen
await expect(session).toHaveElement({
attributes: {
text: 'Hello Jordan'
}
})
})Actions
Sequencing actions
Assertions
expect
toHaveElement
not.toHaveElement
Screenshot comparisons
Network
Helpers
waitForElement
waitForEvent
waitForTimeout
Real life applications
Last updated