Cursor-rules
PromptBeginner5 minmarkdown
.cursorrules
.llmrules
0
0. Always use TypeScript instead of vanilla JavaScript whenever possible.
Sign in to like and favorite skills
.llmrules
Code Style and Structure
Here are some pieces of information you need to know about this project:
getByTestId() locator method to target elements, unless absolutely unable to do so.
getByTestId() is not possible, then using a getByRole() locator is the next best option.getByRole() is not possible, then using a getByPlaceholder() or getByLabel() or getByAltText() locator is the next best option.getByPlaceholder() or getByLabel() or getByAltText() is not possible, then using a getByText() locator is the next best option.
getByText(), always use the { exact: true } option to avoid unwanted partial matches.getByText() is not possible, then use whatever locator Playwright allows you to use to target the element.
DON'T:const exampleSignInButton = page.getByTestId("ExampleButton_signIn"); await exampleSignInButton.click();
await page.getByTestId("ExampleButton_signIn").click();
DON'T:await expect(async () => { await radioButton.click(); // locator defined outside this block await expect(radioButton).toBeChecked(); }).toPass();
The entry point to Playwright's documentation is here if you need to look available features: https://playwright.dev/docs/intro.export async function radioButtonGroupClick( page: Page, urlToWaitFor: string, // The URL where the radio button is radioButton: Locator, errorTextTrigger: Locator // A button you can click that will throw error text if the radio button wasn't clicked ) { await page.waitForURL(urlToWaitFor); let iterationCounter = 0; let errorTextIsVisible = await page.getByTestId("ErrorText").isVisible(); let buttonWasClicked = await radioButton.isChecked(); while (errorTextIsVisible || !buttonWasClicked) { if (iterationCounter === 5) { break; } else { iterationCounter++; } await radioButton.click(); buttonWasClicked = await radioButton.isChecked(); if (buttonWasClicked) { await errorTextTrigger.click(); errorTextIsVisible = await page.getByTestId("ErrorText").isVisible(); } } }
tests/ directory.