File tree 1 file changed +13
-6
lines changed
test/fixtures/nuxt-vitest/tests/nuxt
1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -36,14 +36,21 @@ describe('client-side nuxt features', () => {
36
36
37
37
it ( 'allows pushing to other pages' , async ( ) => {
38
38
await navigateTo ( '/something' )
39
- expect ( useNuxtApp ( ) . $router . currentRoute . value . path ) . toMatchInlineSnapshot (
40
- '" /something" '
39
+ expect ( useNuxtApp ( ) . $router . currentRoute . value . path ) . toEqual (
40
+ '/something'
41
41
)
42
- // It takes two more ticks for the Nuxt useRoute to be updated (as, after suspense resolves,
42
+ // It takes a few ticks for the Nuxt useRoute to be updated (as, after suspense resolves,
43
43
// we wait for a final hook and then update the injected route object )
44
- await nextTick ( )
45
- await nextTick ( )
46
- expect ( useRoute ( ) . path ) . toMatchInlineSnapshot ( '"/something"' )
44
+ const route = useRoute ( )
45
+ await new Promise < void > ( resolve => {
46
+ const unsub = watch ( ( ) => route . path , path => {
47
+ if ( path === '/something' ) {
48
+ unsub ( )
49
+ resolve ( )
50
+ }
51
+ } )
52
+ } )
53
+ expect ( route . path ) . toEqual ( '/something' )
47
54
} )
48
55
} )
49
56
You can’t perform that action at this time.
0 commit comments