Skip to content

Instantly share code, notes, and snippets.

@skovy
Created December 9, 2020 19:25
Show Gist options
  • Save skovy/be19e1349c9ff634b2daa4b5c87a2ed1 to your computer and use it in GitHub Desktop.
Save skovy/be19e1349c9ff634b2daa4b5c87a2ed1 to your computer and use it in GitHub Desktop.
// actions/name.ts
import { screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
export function canPerform() {
try {
return !!screen.getByLabelText(/first name/i) && !!screen.getByLabelText(/last name/i);
} catch (error) {
return false;
}
}
export async function perform() {
try {
await userEvent.type(await screen.findByLabelText(/first name/i), 'Wealth');
await userEvent.type(await screen.findByLabelText(/last name/i), 'Front');
await userEvent.click(await screen.findByText('Next'));
} catch (error) {
// handle the error
}
}
export const name = 'Fill Name & Next';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment