diff --git a/packages/@vue/cli-plugin-e2e-cypress/index.js b/packages/@vue/cli-plugin-e2e-cypress/index.js index 44c571ae3d..6b81b68de9 100644 --- a/packages/@vue/cli-plugin-e2e-cypress/index.js +++ b/packages/@vue/cli-plugin-e2e-cypress/index.js @@ -1,5 +1,5 @@ module.exports = (api, options) => { - const { info, chalk, execa } = require('@vue/cli-shared-utils') + const { info, chalk, execa, resolveModule } = require('@vue/cli-shared-utils') api.registerCommand('test:e2e', { description: 'run e2e tests with Cypress', @@ -31,7 +31,9 @@ module.exports = (api, options) => { ...rawArgs ] - const cypressBinPath = require.resolve('cypress/bin/cypress') + // Use loadModule to allow users to customize their Cypress dependency version. + const cypressBinPath = resolveModule('cypress/bin/cypress', api.getCwd()) || + resolveModule('cypress/bin/cypress', __dirname) const runner = execa(cypressBinPath, cyArgs, { stdio: 'inherit' }) if (server) { runner.on('exit', () => server.close())