Skip to content

Commit 90a4e3a

Browse files
authored
[test] Move test selectors as close to the actual value as possible (Part 2) (#80416)
1 parent c8ac2a5 commit 90a4e3a

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export default async function Page() {
2-
return <section>rewritten</section>
2+
return <section data-testid="content">rewritten</section>
33
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export default async function Page() {
2-
return <section>rewritten</section>
2+
return <section data-testid="content">rewritten</section>
33
}

test/e2e/app-dir/node-extensions/node-extensions.random.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ describe('Node Extensions', () => {
1313
}
1414

1515
it('should not error when accessing middlware that use Math.random()', async () => {
16-
let res, $
16+
let res: Awaited<ReturnType<typeof next.fetch>>,
17+
$: Awaited<ReturnType<typeof next.render$>>
1718

1819
res = await next.fetch('/rewrite')
1920
expect(res.status).toBe(200)
2021
$ = await next.render$('/rewrite')
21-
expect($('main section').text()).toBe('rewritten')
22+
expect($('[data-testid="content"]').text()).toBe('rewritten')
2223
})
2324

2425
it('should not error when accessing pages that use Math.random() in App Router', async () => {
@@ -165,7 +166,7 @@ describe('Node Extensions', () => {
165166
res = await next.fetch('/rewrite')
166167
expect(res.status).toBe(200)
167168
$ = await next.render$('/rewrite')
168-
expect($('main section').text()).toBe('rewritten')
169+
expect($('[data-testid="content"]').text()).toBe('rewritten')
169170
})
170171

171172
it('should not error when accessing pages that use Math.random() in App Router', async () => {

0 commit comments

Comments
 (0)