mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-04-29 16:30:33 -05:00
make tests work on appveyor
This commit is contained in:
@@ -6,6 +6,7 @@ install:
|
||||
- yarn
|
||||
|
||||
test_script:
|
||||
- git --version
|
||||
- node --version
|
||||
- yarn --version
|
||||
- yarn test
|
||||
|
||||
+1
-1
@@ -41,6 +41,6 @@
|
||||
"lint-staged": "^6.0.0",
|
||||
"memfs": "^2.6.0",
|
||||
"puppeteer": "^0.13.0",
|
||||
"yorkie": "^1.0.1"
|
||||
"yorkie": "^1.0.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,9 @@ test('should work', async () => {
|
||||
expect(hook).toMatch('#yorkie')
|
||||
await write('src/main.js', updatedMain)
|
||||
// nvm doesn't like PREFIX env
|
||||
delete process.env.PREFIX
|
||||
if (process.platform === 'darwin') {
|
||||
delete process.env.PREFIX
|
||||
}
|
||||
await run('git add -A')
|
||||
await run('git commit -m save')
|
||||
// should be linted on commit
|
||||
|
||||
@@ -3,7 +3,7 @@ jest.setTimeout(20000)
|
||||
const create = require('@vue/cli-test-utils/createTestProject')
|
||||
|
||||
test('should work', async () => {
|
||||
const { run } = await create('unit-mocha-webpack', {
|
||||
const project = await create('unit-mocha-webpack', {
|
||||
plugins: {
|
||||
'@vue/cli-plugin-babel': {},
|
||||
'@vue/cli-plugin-unit-mocha-webpack': {
|
||||
@@ -11,5 +11,5 @@ test('should work', async () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
await run(`vue-cli-service test`)
|
||||
await project.run(`vue-cli-service test`)
|
||||
})
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
jest.setTimeout(20000)
|
||||
jest.setTimeout(30000)
|
||||
|
||||
const { defaults } = require('@vue/cli/lib/options')
|
||||
const create = require('@vue/cli-test-utils/createTestProject')
|
||||
@@ -9,16 +9,15 @@ const sleep = n => new Promise(resolve => setTimeout(resolve, n))
|
||||
test('serve', async () => {
|
||||
const project = await create('e2e-serve', defaults)
|
||||
|
||||
await serve(project, async ({ nextUpdate, assertText }) => {
|
||||
await serve(project, async ({ nextUpdate, getText }) => {
|
||||
const msg = `Welcome to Your Vue.js App`
|
||||
await assertText('h1', msg)
|
||||
expect(await getText('h1')).toMatch(msg)
|
||||
|
||||
// test hot reload
|
||||
const file = await project.read(`src/App.vue`)
|
||||
await project.write(`src/App.vue`, file.replace(msg, `Updated`))
|
||||
|
||||
project.write(`src/App.vue`, file.replace(msg, `Updated`))
|
||||
await nextUpdate() // wait for child stdout update signal
|
||||
await sleep(process.env.CI ? 3000 : 500) // give the client time to update
|
||||
await assertText('h1', `Updated`)
|
||||
await sleep(1000) // give the client time to update
|
||||
expect(await getText('h1')).toMatch(`Updated`)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -61,8 +61,7 @@ module.exports = (api, options) => {
|
||||
)
|
||||
|
||||
if (!isProduction) {
|
||||
// inject dev/hot client
|
||||
addDevClientToEntry(webpackConfig, [
|
||||
const devClients = [
|
||||
// dev server client
|
||||
`webpack-dev-server/client/?${urls.localUrlForBrowser}`,
|
||||
// hmr client
|
||||
@@ -71,12 +70,19 @@ module.exports = (api, options) => {
|
||||
: 'webpack/hot/dev-server'
|
||||
// TODO custom overlay client
|
||||
// `@vue/cli-overlay/dist/client`
|
||||
])
|
||||
]
|
||||
if (process.env.APPVEYOR) {
|
||||
devClients.push(`webpack/hot/poll?500`)
|
||||
}
|
||||
// inject dev/hot client
|
||||
addDevClientToEntry(webpackConfig, devClients)
|
||||
}
|
||||
|
||||
const compiler = webpack(webpackConfig)
|
||||
|
||||
compiler.apply(new webpack.ProgressPlugin())
|
||||
if (!process.env.VUE_CLI_TEST) {
|
||||
compiler.apply(new webpack.ProgressPlugin())
|
||||
}
|
||||
|
||||
// log instructions & open browser on first compilation complete
|
||||
let isFirstCompile = true
|
||||
@@ -129,7 +135,7 @@ module.exports = (api, options) => {
|
||||
watchContentBase: !isProduction,
|
||||
hot: !isProduction,
|
||||
quiet: true,
|
||||
compress: true,
|
||||
compress: isProduction,
|
||||
publicPath: '/',
|
||||
overlay: isProduction // TODO disable this
|
||||
? false
|
||||
@@ -154,11 +160,24 @@ module.exports = (api, options) => {
|
||||
;['SIGINT', 'SIGTERM'].forEach(signal => {
|
||||
process.on(signal, () => {
|
||||
server.close(() => {
|
||||
process.exit()
|
||||
process.exit(0)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
// on appveyor, killing the process with SIGTERM causes execa to
|
||||
// throw error
|
||||
if (process.env.VUE_CLI_TEST) {
|
||||
process.stdin.on('data', data => {
|
||||
if (data.toString() === 'close') {
|
||||
console.log('got close signal!')
|
||||
server.close(() => {
|
||||
process.exit(0)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
server.listen(port, host, err => {
|
||||
if (err) {
|
||||
return error(err)
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
"webpack-chain": "^4.5.0",
|
||||
"webpack-dev-server": "^2.10.0",
|
||||
"webpack-merge": "^4.1.1",
|
||||
"yorkie": "^1.0.1"
|
||||
"yorkie": "^1.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"vue": "^2.5.13"
|
||||
|
||||
@@ -28,12 +28,12 @@ module.exports = function createTestProject (name, config, cwd) {
|
||||
}
|
||||
|
||||
const run = (command, args) => {
|
||||
if (!args) { [command, ...args] = command.split(/\s+/) }
|
||||
const child = execa(command, args, { cwd: projectRoot })
|
||||
child.then(({ code, stderr }) => {
|
||||
if (code !== 0 && stderr) console.error(stderr)
|
||||
})
|
||||
return child
|
||||
[command, ...args] = command.split(/\s+/)
|
||||
if (command === 'vue-cli-service') {
|
||||
// appveyor has problem with paths sometimes
|
||||
command = require.resolve('@vue/cli-service/bin/vue-cli-service')
|
||||
}
|
||||
return execa(command, args, { cwd: projectRoot })
|
||||
}
|
||||
|
||||
const cliBinPath = require.resolve('@vue/cli/bin/vue')
|
||||
|
||||
@@ -18,7 +18,7 @@ module.exports = async function serveWithPuppeteer (
|
||||
})
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
await new Promise((resolve, reject) => {
|
||||
child = project.run('vue-cli-service serve')
|
||||
|
||||
let isFirstMatch = true
|
||||
@@ -33,11 +33,10 @@ module.exports = async function serveWithPuppeteer (
|
||||
const url = urlMatch[0]
|
||||
await page.goto(url)
|
||||
|
||||
const assertText = async (selector, text) => {
|
||||
const value = await page.evaluate(() => {
|
||||
return document.querySelector('h1').textContent
|
||||
})
|
||||
expect(value).toMatch(text)
|
||||
const getText = selector => {
|
||||
return page.evaluate(selector => {
|
||||
return document.querySelector(selector).textContent
|
||||
}, selector)
|
||||
}
|
||||
|
||||
await testFn({
|
||||
@@ -45,13 +44,16 @@ module.exports = async function serveWithPuppeteer (
|
||||
page,
|
||||
url,
|
||||
nextUpdate,
|
||||
assertText
|
||||
getText
|
||||
})
|
||||
|
||||
await browser.close()
|
||||
browser = null
|
||||
child.kill()
|
||||
// on appveyor, the spawned server process doesn't exit
|
||||
// and causes the build to hang.
|
||||
child.stdin.write('close')
|
||||
child = null
|
||||
// kill(child.pid)
|
||||
resolve()
|
||||
} else if (data.toString().match(/App updated/)) {
|
||||
if (notifyUpdate) {
|
||||
@@ -63,7 +65,7 @@ module.exports = async function serveWithPuppeteer (
|
||||
await browser.close()
|
||||
}
|
||||
if (child) {
|
||||
child.kill()
|
||||
child.stdin.write('close')
|
||||
}
|
||||
reject(err)
|
||||
}
|
||||
|
||||
@@ -8774,6 +8774,10 @@ tr46@^1.0.0:
|
||||
dependencies:
|
||||
punycode "^2.1.0"
|
||||
|
||||
tree-kill@^1.2.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/tree-kill/-/tree-kill-1.2.0.tgz#5846786237b4239014f05db156b643212d4c6f36"
|
||||
|
||||
trim-newlines@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613"
|
||||
@@ -9618,9 +9622,9 @@ yauzl@^2.4.2:
|
||||
buffer-crc32 "~0.2.3"
|
||||
fd-slicer "~1.0.1"
|
||||
|
||||
yorkie@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/yorkie/-/yorkie-1.0.1.tgz#7bbd6e6c7dba8f637dea82fdb695c7c18c570002"
|
||||
yorkie@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/yorkie/-/yorkie-1.0.2.tgz#910f47a06f8eab05e99e73080ebce1bc9d55c3dd"
|
||||
dependencies:
|
||||
execa "^0.8.0"
|
||||
is-ci "^1.0.10"
|
||||
|
||||
Reference in New Issue
Block a user