Skip to content

Commit

Permalink
fix: output warning in dev mode
Browse files Browse the repository at this point in the history
  • Loading branch information
wattanx committed Mar 10, 2024
1 parent f918460 commit 131be8d
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions test/bridge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,15 @@ describe('pages', () => {
expect(html).toContain('Hello Vue 2!')
expect(html).toContain('public:{myValue:123}')

const { consoleLogs } = await renderPage('/')

if (isWebpack && isNoResolve) {
// throw client error in webpack no-resolve
expect(consoleLogs.some(i => i.type === 'error')).toBeTruthy()
} else if (isDev) {
// output [legacy capi] warning
expect(consoleLogs.some(i => i.type === 'warning')).toBeTruthy()
} else {
await expectNoClientErrors('/')
expect(consoleLogs.some(i => i.type === 'error' || i.type === 'warning')).toBeFalsy()
}
})
it('uses server Vue build', async () => {
Expand Down Expand Up @@ -168,21 +173,20 @@ describe('navigate', () => {
const { headers } = await fetch('/navigate-to/', { redirect: 'manual' })
expect(headers.get('location')).toEqual('/navigation-target')

const { consoleLogs } = await renderPage('/navigate-to/')

if (isWebpack && isNoResolve) {
// throw client error in webpack no-resolve
expect(consoleLogs.some(i => i.type === 'error')).toBeTruthy()
} else if (isDev) {
// output [legacy capi] warning
expect(consoleLogs.some(i => i.type === 'warning')).toBeTruthy()
} else {
await expectNoClientErrors('/navigate-to/')
expect(consoleLogs.some(i => i.type === 'error' || i.type === 'warning')).toBeFalsy()
}
})
it('should redirect to index with navigateTo and 301 code', async () => {
const res = await fetch('/navigate-to/', { redirect: 'manual' })
expect(res.status).toBe(301)

if (isWebpack && isNoResolve) {
// throw client error in webpack no-resolve
} else {
await expectNoClientErrors('/navigate-to/')
}
})
})

Expand All @@ -199,10 +203,15 @@ describe('legacy capi', () => {
const html = await $fetch('/legacy-capi')
expect(html).toMatch(/([\s\S]*✅){11}/)

const { consoleLogs } = await renderPage('/legacy-capi')

if (isWebpack && isNoResolve) {
// throw client error in webpack no-resolve
expect(consoleLogs.some(i => i.type === 'error')).toBeTruthy()
} else if (isDev) {
// output [legacy capi] warning
expect(consoleLogs.some(i => i.type === 'warning')).toBeTruthy()
} else {
await expectNoClientErrors('/legacy-capi')
expect(consoleLogs.some(i => i.type === 'error' || i.type === 'warning')).toBeFalsy()
}
})

Expand Down

0 comments on commit 131be8d

Please sign in to comment.