Skip to content

Instantly share code, notes, and snippets.

@skovy

skovy/name.ts

Created Dec 9, 2020
Embed
What would you like to do?
// 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
You can’t perform that action at this time.