Skip to content

Commit d25dd9f

Browse files
committed
test: test for optional public dir
1 parent 1719622 commit d25dd9f

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

packages/@vue/cli-service/__tests__/serve.spec.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
jest.setTimeout(45000)
22

3+
const path = require('path')
4+
const fs = require('fs-extra')
35
const { defaultPreset } = require('@vue/cli/lib/options')
46
const create = require('@vue/cli-test-utils/createTestProject')
57
const serve = require('@vue/cli-test-utils/serveWithPuppeteer')
@@ -50,8 +52,6 @@ test('serve with router', async () => {
5052
test('serve with inline entry', async () => {
5153
const project = await create('e2e-serve-inline-entry', defaultPreset)
5254

53-
const path = require('path')
54-
const fs = require('fs-extra')
5555
await fs.move(
5656
path.resolve(project.dir, 'src/main.js'),
5757
path.resolve(project.dir, 'src/index.js')
@@ -72,3 +72,24 @@ test('serve with inline entry', async () => {
7272
}
7373
)
7474
})
75+
76+
test('serve with no public dir', async () => {
77+
const project = await create('e2e-serve-no-public', defaultPreset)
78+
79+
await fs.remove(path.resolve(project.dir, 'public'))
80+
81+
await serve(
82+
() => project.run('vue-cli-service serve'),
83+
async ({ nextUpdate, helpers }) => {
84+
const msg = `Welcome to Your Vue.js App`
85+
expect(await helpers.getText('h1')).toMatch(msg)
86+
87+
// test hot reload
88+
const file = await project.read(`src/App.vue`)
89+
project.write(`src/App.vue`, file.replace(msg, `Updated`))
90+
await nextUpdate() // wait for child stdout update signal
91+
await sleep(1000) // give the client time to update
92+
expect(await helpers.getText('h1')).toMatch(`Updated`)
93+
}
94+
)
95+
})

0 commit comments

Comments
 (0)