Skip to content

Commit

Permalink
on
Browse files Browse the repository at this point in the history
  • Loading branch information
seren5240 committed Apr 13, 2024
1 parent 3537177 commit e58ff84
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion .grit/patterns/js/cypress_to_playwright.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ pattern convert_cypress_queries() {
`cy.visit($loc)` => `await page.goto($loc)`,
`cy.get($locator)` => `page.locator($locator)`,
`cy.contains($text, $options)` => `await expect(page.getByText($text)).toBeVisible($options)`,
`cy.get($locator).contains($text).$action()` => `await page.locator($locator, { hasText: $text }).click()`,
`cy.get($locator).contains($text).$action()` => `await page.locator($locator, { hasText: $text }).$action()`,
`cy.get($locator).contains($text)` => `page.locator($locator, { hasText: $text })`,
`cy.contains($text)` => `await expect(page.getByText($text)).toBeVisible()`,
`cy.log($log)` => `console.log($log)`,
`cy.wait($timeout)` => `await page.waitForTimeout($timeout)`,
Expand All @@ -53,6 +54,15 @@ pattern convert_cypress_queries() {
`cy.onlyOn($var === $cond)` => `if ($var !== $cond) {
test.skip();
}`,
`cy.$_($selector).each(($locator) => {
$body
})` as $loop where {
$var = `$[locator]s`,
$loop => `const $var = await page.locator($selector).all();
for (const $locator of $var) {
$body
}`
},
`cy.request({ $opts })` as $req where {
or {
$opts <: contains pair(key=`method`, value=`"$method"`),
Expand Down

0 comments on commit e58ff84

Please sign in to comment.