Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a single websocket connection for HMR #5069

Merged
merged 3 commits into from Jan 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/@vue/cli-service/__tests__/serve.spec.js
Expand Up @@ -180,3 +180,17 @@ test('dart sass', async () => {
// should build successfully
await project.run('vue-cli-service build')
})

test('use a single websocket connection for HMR', async () => {
const project = await create('e2e-serve-hmr', defaultPreset)

await serve(
() => project.run('vue-cli-service serve'),
async ({ helpers, requestUrls }) => {
const msg = `Welcome to Your Vue.js App`
expect(await helpers.getText('h1')).toMatch(msg)

expect(requestUrls.filter(url => url.includes('sockjs-node')).length).toBe(1)
}
)
})
1 change: 1 addition & 0 deletions packages/@vue/cli-service/lib/commands/serve.js
Expand Up @@ -172,6 +172,7 @@ module.exports = (api, options) => {
contentBase: api.resolve('public'),
watchContentBase: !isProduction,
hot: !isProduction,
injectClient: false,
compress: isProduction,
publicPath: options.publicPath,
overlay: isProduction // TODO disable this
Expand Down
9 changes: 8 additions & 1 deletion packages/@vue/cli-test-utils/launchPuppeteer.js
Expand Up @@ -9,9 +9,16 @@ module.exports = async function launchPuppeteer (url) {
const page = await browser.newPage()

const logs = []
const requestUrls = []
page.on('console', msg => logs.push(msg.text()))

await page.setRequestInterception(true)
page.on('request', interceptedRequest => {
requestUrls.push(interceptedRequest.url())
interceptedRequest.continue()
})

await page.goto(url)

return { browser, page, logs }
return { browser, page, logs, requestUrls }
}
5 changes: 3 additions & 2 deletions packages/@vue/cli-test-utils/serveWithPuppeteer.js
Expand Up @@ -44,7 +44,7 @@ module.exports = async function serveWithPuppeteer (serve, test, noPuppeteer) {
await test({ url })
} else {
// start browser
const { page, browser } = await launchPuppeteer(url)
const { page, browser, requestUrls } = await launchPuppeteer(url)
activeBrowser = browser

const helpers = createHelpers(page)
Expand All @@ -54,7 +54,8 @@ module.exports = async function serveWithPuppeteer (serve, test, noPuppeteer) {
page,
url,
nextUpdate,
helpers
helpers,
requestUrls
})

await browser.close()
Expand Down