Skip to content

Commit d1c881e

Browse files
committed
test(e2e): fix locator usage
1 parent ff460a2 commit d1c881e

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

e2e/tests/components/auto-link.spec.ts

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,31 @@ test.beforeEach(async ({ page }) => {
66
})
77

88
test('should render route-link correctly', async ({ page }) => {
9-
for (const el of await page
10-
.locator('.e2e-theme-content #route-link a')
11-
.all()) {
9+
const locator = page.locator('.e2e-theme-content #route-link a')
10+
for (const el of await locator.all()) {
1211
await expect(el).toHaveAttribute('class', /route-link/)
1312
}
1413
})
1514

1615
test('should render external-link correctly', async ({ page }) => {
17-
for (const el of await page
18-
.locator('.e2e-theme-content #external-link a')
19-
.all()) {
16+
const locator = page.locator('.e2e-theme-content #external-link a')
17+
for (const el of await locator.all()) {
2018
await expect(el).toHaveAttribute('class', /external-link/)
2119
}
2220
})
2321

2422
test('should render config correctly', async ({ page }) => {
2523
const locator = page.locator('.e2e-theme-content #config a')
2624

27-
await expect(await locator.nth(0)).toHaveText('text1')
28-
await expect(await locator.nth(0)).toHaveAttribute('href', BASE)
29-
await expect(await locator.nth(0)).toHaveAttribute('aria-label', 'label')
25+
await expect(locator.nth(0)).toHaveText('text1')
26+
await expect(locator.nth(0)).toHaveAttribute('href', BASE)
27+
await expect(locator.nth(0)).toHaveAttribute('aria-label', 'label')
3028

31-
await expect(await locator.nth(1)).toHaveText('text2')
32-
await expect(await locator.nth(1)).toHaveAttribute(
29+
await expect(locator.nth(1)).toHaveText('text2')
30+
await expect(locator.nth(1)).toHaveAttribute(
3331
'href',
3432
'https://example.com/test/',
3533
)
36-
await expect(await locator.nth(1)).toHaveAttribute('target', '_blank')
37-
await expect(await locator.nth(1)).toHaveAttribute(
38-
'rel',
39-
'noopener noreferrer',
40-
)
34+
await expect(locator.nth(1)).toHaveAttribute('target', '_blank')
35+
await expect(locator.nth(1)).toHaveAttribute('rel', 'noopener noreferrer')
4136
})

0 commit comments

Comments
 (0)