Skip to content

Commit a1b3057

Browse files
committed
test: configure test hooks sequence order, remove workaround
1 parent 0fbc19f commit a1b3057

File tree

3 files changed

+53
-76
lines changed

3 files changed

+53
-76
lines changed

packages/vue/__tests__/e2e/Transition.spec.ts

Lines changed: 38 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,13 @@ describe('e2e: Transition', () => {
2121
})
2222
})
2323

24-
// beforeEach(async () => {
25-
// await page().goto(baseUrl)
26-
// await page().waitForSelector('#app')
27-
// })
28-
29-
// workaround for https://github.com/vitest-dev/vitest/issues/2756
30-
function runTest(desc: string, runner: any, timeout?: number) {
31-
test(
32-
desc,
33-
async () => {
34-
await page().goto(baseUrl)
35-
await page().waitForSelector('#app')
36-
await runner()
37-
},
38-
timeout
39-
)
40-
}
24+
beforeEach(async () => {
25+
await page().goto(baseUrl)
26+
await page().waitForSelector('#app')
27+
})
4128

4229
describe('transition with v-if', () => {
43-
runTest(
30+
test(
4431
'basic transition',
4532
async () => {
4633
await page().goto(baseUrl)
@@ -98,7 +85,7 @@ describe('e2e: Transition', () => {
9885
E2E_TIMEOUT
9986
)
10087

101-
runTest(
88+
test(
10289
'named transition',
10390
async () => {
10491
await page().evaluate(() => {
@@ -154,7 +141,7 @@ describe('e2e: Transition', () => {
154141
E2E_TIMEOUT
155142
)
156143

157-
runTest(
144+
test(
158145
'custom transition classes',
159146
async () => {
160147
await page().evaluate(() => {
@@ -215,7 +202,7 @@ describe('e2e: Transition', () => {
215202
E2E_TIMEOUT
216203
)
217204

218-
runTest(
205+
test(
219206
'transition with dynamic name',
220207
async () => {
221208
await page().evaluate(() => {
@@ -277,7 +264,7 @@ describe('e2e: Transition', () => {
277264
E2E_TIMEOUT
278265
)
279266

280-
runTest(
267+
test(
281268
'transition events without appear',
282269
async () => {
283270
const beforeLeaveSpy = vi.fn()
@@ -381,7 +368,7 @@ describe('e2e: Transition', () => {
381368
E2E_TIMEOUT
382369
)
383370

384-
runTest(
371+
test(
385372
'events with arguments',
386373
async () => {
387374
const beforeLeaveSpy = vi.fn()
@@ -497,7 +484,7 @@ describe('e2e: Transition', () => {
497484
E2E_TIMEOUT
498485
)
499486

500-
runTest('onEnterCancelled', async () => {
487+
test('onEnterCancelled', async () => {
501488
const enterCancelledSpy = vi.fn()
502489

503490
await page().exposeFunction('enterCancelledSpy', enterCancelledSpy)
@@ -559,7 +546,7 @@ describe('e2e: Transition', () => {
559546
expect(await html('#container')).toBe('<!--v-if-->')
560547
})
561548

562-
runTest(
549+
test(
563550
'transition on appear',
564551
async () => {
565552
const appearClass = await page().evaluate(async () => {
@@ -635,7 +622,7 @@ describe('e2e: Transition', () => {
635622
E2E_TIMEOUT
636623
)
637624

638-
runTest(
625+
test(
639626
'transition events with appear',
640627
async () => {
641628
const onLeaveSpy = vi.fn()
@@ -783,7 +770,7 @@ describe('e2e: Transition', () => {
783770
E2E_TIMEOUT
784771
)
785772

786-
runTest(
773+
test(
787774
'css: false',
788775
async () => {
789776
const onBeforeEnterSpy = vi.fn()
@@ -861,7 +848,7 @@ describe('e2e: Transition', () => {
861848
E2E_TIMEOUT
862849
)
863850

864-
runTest(
851+
test(
865852
'no transition detected',
866853
async () => {
867854
await page().evaluate(() => {
@@ -903,7 +890,7 @@ describe('e2e: Transition', () => {
903890
E2E_TIMEOUT
904891
)
905892

906-
runTest(
893+
test(
907894
'animations',
908895
async () => {
909896
await page().evaluate(() => {
@@ -955,7 +942,7 @@ describe('e2e: Transition', () => {
955942
E2E_TIMEOUT
956943
)
957944

958-
runTest(
945+
test(
959946
'explicit transition type',
960947
async () => {
961948
await page().evaluate(() => {
@@ -1025,7 +1012,7 @@ describe('e2e: Transition', () => {
10251012
E2E_TIMEOUT
10261013
)
10271014

1028-
runTest(
1015+
test(
10291016
'transition on SVG elements',
10301017
async () => {
10311018
await page().evaluate(() => {
@@ -1096,7 +1083,7 @@ describe('e2e: Transition', () => {
10961083
E2E_TIMEOUT
10971084
)
10981085

1099-
runTest(
1086+
test(
11001087
'custom transition higher-order component',
11011088
async () => {
11021089
await page().evaluate(() => {
@@ -1153,7 +1140,7 @@ describe('e2e: Transition', () => {
11531140
E2E_TIMEOUT
11541141
)
11551142

1156-
runTest(
1143+
test(
11571144
'transition on child components with empty root node',
11581145
async () => {
11591146
await page().evaluate(() => {
@@ -1232,7 +1219,7 @@ describe('e2e: Transition', () => {
12321219

12331220
describe('transition with Suspense', () => {
12341221
// #1583
1235-
runTest(
1222+
test(
12361223
'async component transition inside Suspense',
12371224
async () => {
12381225
const onLeaveSpy = vi.fn()
@@ -1326,7 +1313,7 @@ describe('e2e: Transition', () => {
13261313
)
13271314

13281315
// #1689
1329-
runTest(
1316+
test(
13301317
'static node transition inside Suspense',
13311318
async () => {
13321319
await page().evaluate(() => {
@@ -1384,7 +1371,7 @@ describe('e2e: Transition', () => {
13841371
E2E_TIMEOUT
13851372
)
13861373

1387-
runTest(
1374+
test(
13881375
'out-in mode with Suspense',
13891376
async () => {
13901377
const onLeaveSpy = vi.fn()
@@ -1451,7 +1438,7 @@ describe('e2e: Transition', () => {
14511438
)
14521439

14531440
// #3963
1454-
runTest(
1441+
test(
14551442
'Suspense fallback should work with transition',
14561443
async () => {
14571444
await page().evaluate(() => {
@@ -1515,7 +1502,7 @@ describe('e2e: Transition', () => {
15151502
})
15161503

15171504
describe('transition with v-show', () => {
1518-
runTest(
1505+
test(
15191506
'named transition with v-show',
15201507
async () => {
15211508
await page().evaluate(() => {
@@ -1574,7 +1561,7 @@ describe('e2e: Transition', () => {
15741561
E2E_TIMEOUT
15751562
)
15761563

1577-
runTest(
1564+
test(
15781565
'transition events with v-show',
15791566
async () => {
15801567
const beforeLeaveSpy = vi.fn()
@@ -1680,7 +1667,7 @@ describe('e2e: Transition', () => {
16801667
E2E_TIMEOUT
16811668
)
16821669

1683-
runTest(
1670+
test(
16841671
'onLeaveCancelled (v-show only)',
16851672
async () => {
16861673
const onLeaveCancelledSpy = vi.fn()
@@ -1742,7 +1729,7 @@ describe('e2e: Transition', () => {
17421729
E2E_TIMEOUT
17431730
)
17441731

1745-
runTest(
1732+
test(
17461733
'transition on appear with v-show',
17471734
async () => {
17481735
const beforeEnterSpy = vi.fn()
@@ -1848,7 +1835,7 @@ describe('e2e: Transition', () => {
18481835
)
18491836

18501837
// #4845
1851-
runTest(
1838+
test(
18521839
'transition events should not call onEnter with v-show false',
18531840
async () => {
18541841
const beforeEnterSpy = vi.fn()
@@ -1922,7 +1909,7 @@ describe('e2e: Transition', () => {
19221909
})
19231910

19241911
describe('explicit durations', () => {
1925-
runTest(
1912+
test(
19261913
'single value',
19271914
async () => {
19281915
await page().evaluate(duration => {
@@ -1978,7 +1965,7 @@ describe('e2e: Transition', () => {
19781965
E2E_TIMEOUT
19791966
)
19801967

1981-
runTest(
1968+
test(
19821969
'enter with explicit durations',
19831970
async () => {
19841971
await page().evaluate(duration => {
@@ -2034,7 +2021,7 @@ describe('e2e: Transition', () => {
20342021
E2E_TIMEOUT
20352022
)
20362023

2037-
runTest(
2024+
test(
20382025
'leave with explicit durations',
20392026
async () => {
20402027
await page().evaluate(duration => {
@@ -2090,7 +2077,7 @@ describe('e2e: Transition', () => {
20902077
E2E_TIMEOUT
20912078
)
20922079

2093-
runTest(
2080+
test(
20942081
'separate enter and leave',
20952082
async () => {
20962083
await page().evaluate(duration => {
@@ -2149,7 +2136,7 @@ describe('e2e: Transition', () => {
21492136
E2E_TIMEOUT
21502137
)
21512138

2152-
runTest(
2139+
test(
21532140
'warn invalid durations',
21542141
async () => {
21552142
createApp({
@@ -2187,7 +2174,7 @@ describe('e2e: Transition', () => {
21872174
)
21882175
})
21892176

2190-
runTest('warn when used on multiple elements', async () => {
2177+
test('warn when used on multiple elements', async () => {
21912178
createApp({
21922179
render() {
21932180
return h(Transition, null, {
@@ -2200,7 +2187,7 @@ describe('e2e: Transition', () => {
22002187
).toHaveBeenWarned()
22012188
})
22022189

2203-
runTest('warn when invalid transition mode', () => {
2190+
test('warn when invalid transition mode', () => {
22042191
createApp({
22052192
template: `
22062193
<div id="container">
@@ -2214,7 +2201,7 @@ describe('e2e: Transition', () => {
22142201
})
22152202

22162203
// #3227
2217-
runTest(`HOC w/ merged hooks`, async () => {
2204+
test(`HOC w/ merged hooks`, async () => {
22182205
const innerSpy = vi.fn()
22192206
const outerSpy = vi.fn()
22202207

@@ -2253,7 +2240,7 @@ describe('e2e: Transition', () => {
22532240
expect(root.innerHTML).toBe(`<!---->`)
22542241
})
22552242

2256-
runTest(
2243+
test(
22572244
'should work with dev root fragment',
22582245
async () => {
22592246
await page().evaluate(() => {

0 commit comments

Comments
 (0)