Skip to content

Commit

Permalink
fix(nightwatch): should not install corresponding webdriver if the br…
Browse files Browse the repository at this point in the history
…owser is unselected (#5528)
  • Loading branch information
sodatea committed Jun 18, 2020
1 parent a41cac2 commit 795b277
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions packages/@vue/cli-plugin-e2e-nightwatch/generator/index.js
@@ -1,30 +1,33 @@
const { installedBrowsers } = require('@vue/cli-shared-utils')

module.exports = api => {
module.exports = (api, { webdrivers }) => {
api.render('./template', {
hasTS: api.hasPlugin('typescript'),
hasESLint: api.hasPlugin('eslint')
})

const devDependencies = {}

// Use devDependencies to store latest version number so as to automate update
const devDeps = require('../package.json').devDependencies
const geckodriver = devDeps.geckodriver
const pluginDeps = require('../package.json').devDependencies

// chromedriver major version bumps every 6 weeks following Chrome
// so there may be a mismatch between
// user's installed browser version and the default provided version
// fallback to the devDependencies version in case detection fails
const chromedriver = installedBrowsers.chrome
? installedBrowsers.chrome.match(/^(\d+)\./)[1]
: devDeps.chromedriver
if (webdrivers && webdrivers.includes('firefox')) {
devDependencies.geckodriver = pluginDeps.geckodriver
}
if (webdrivers && webdrivers.includes('chrome')) {
// chromedriver major version bumps every 6 weeks following Chrome
// so there may be a mismatch between
// user's installed browser version and the default provided version
// fallback to the devDependencies version in case detection fails
devDependencies.chromedriver = installedBrowsers.chrome
? installedBrowsers.chrome.match(/^(\d+)\./)[1]
: pluginDeps.chromedriver
}

api.extendPackage({
scripts: {
'test:e2e': 'vue-cli-service test:e2e'
},
devDependencies: {
chromedriver,
geckodriver
}
devDependencies
})
}

0 comments on commit 795b277

Please sign in to comment.