Skip to content

Commit

Permalink
chore: fix ssr tests (#8313)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed May 24, 2022
1 parent 809ab47 commit a0fc01a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
2 changes: 2 additions & 0 deletions playground/ssr-react/__tests__/ssr-react.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ test('/', async () => {
})

test('hmr', async () => {
await page.goto(url)
editFile('src/pages/Home.jsx', (code) =>
code.replace('<h1>Home', '<h1>changed')
)
await untilUpdated(() => page.textContent('h1'), 'changed')
})

test('client navigation', async () => {
await page.goto(url)
await untilUpdated(() => page.textContent('a[href="/about"]'), 'About')
await page.click('a[href="/about"]')
await untilUpdated(() => page.textContent('h1'), 'About')
Expand Down
17 changes: 10 additions & 7 deletions playground/ssr-vue/__tests__/ssr-vue.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {
const url = `http://localhost:${port}`

test('vuex can be import succeed by named import', async () => {
await page.goto(url + '/store')
// wait networkidle for dynamic optimize vuex
await page.goto(url + '/store', { waitUntil: 'networkidle' })
expect(await page.textContent('h1')).toMatch('bar')

// raw http request
Expand Down Expand Up @@ -111,19 +112,18 @@ test('/', async () => {
})

test('css', async () => {
await page.goto(url)
if (isBuild) {
expect(await getColor('h1')).toBe('green')
expect(await getColor('.jsx')).toBe('blue')
} else {
// During dev, the CSS is loaded from async chunk and we may have to wait
// when the test runs concurrently.
await page.waitForLoadState('networkidle')
await untilUpdated(() => getColor('h1'), 'green')
await untilUpdated(() => getColor('.jsx'), 'blue')
}
})

test('asset', async () => {
await page.goto(url)
// should have no 404s
browserLogs.forEach((msg) => {
expect(msg).not.toMatch('404')
Expand All @@ -135,36 +135,39 @@ test('asset', async () => {
})

test('jsx', async () => {
await page.goto(url)
expect(await page.textContent('.jsx')).toMatch('from JSX')
})

test('virtual module', async () => {
await page.goto(url)
expect(await page.textContent('.virtual')).toMatch('hi')
})

test('nested virtual module', async () => {
await page.goto(url)
expect(await page.textContent('.nested-virtual')).toMatch('[success]')
})

test('hydration', async () => {
await page.goto(url)
expect(await page.textContent('button')).toMatch('0')
await page.click('button')
await page.waitForLoadState('networkidle')
expect(await page.textContent('button')).toMatch('1')
})

test('hmr', async () => {
await page.goto(url)
editFile('src/pages/Home.vue', (code) => code.replace('Home', 'changed'))
await page.waitForLoadState('networkidle')
await untilUpdated(() => page.textContent('h1'), 'changed')
})

test('client navigation', async () => {
await page.goto(url)
await untilUpdated(() => page.textContent('a[href="/about"]'), 'About')
await page.click('a[href="/about"]')
await untilUpdated(() => page.textContent('h1'), 'About')
editFile('src/pages/About.vue', (code) => code.replace('About', 'changed'))
await page.waitForLoadState('networkidle')
await untilUpdated(() => page.textContent('h1'), 'changed')
await page.click('a[href="/"]')
await untilUpdated(() => page.textContent('a[href="/"]'), 'Home')
Expand Down
3 changes: 3 additions & 0 deletions playground/ssr-vue/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,8 @@ module.exports = {
// this package has uncompiled .vue files
'example-external-component'
]
},
optimizeDeps: {
exclude: ['example-external-component']
}
}
3 changes: 3 additions & 0 deletions playground/ssr-vue/vite.config.noexternal.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ module.exports = Object.assign(config, {
replacement: '@vue/runtime-core/dist/runtime-core.cjs.js'
}
]
},
optimizeDeps: {
exclude: ['example-external-component']
}
})

0 comments on commit a0fc01a

Please sign in to comment.