e2e.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. const { installedBrowsers } = require('@vue/cli-shared-utils')
  2. module.exports = cli => {
  3. cli.injectFeature({
  4. name: 'E2E Testing',
  5. value: 'e2e',
  6. short: 'E2E',
  7. description: 'Add an End-to-End testing solution to the app like Cypress or Nightwatch',
  8. link: 'https://github.com/vuejs/vue-cli/tree/dev/docs#e2e-testing',
  9. plugins: ['e2e-cypress', 'e2e-nightwatch']
  10. })
  11. cli.injectPrompt({
  12. name: 'e2e',
  13. when: answers => answers.features.includes('e2e'),
  14. type: 'list',
  15. message: 'Pick a E2E testing solution:',
  16. choices: [
  17. {
  18. name: 'Cypress (Chrome only)',
  19. value: 'cypress',
  20. short: 'Cypress'
  21. },
  22. {
  23. name: 'Nightwatch (WebDriver-based)',
  24. value: 'nightwatch',
  25. short: 'Nightwatch'
  26. }
  27. ]
  28. })
  29. cli.injectPrompt({
  30. name: 'webdrivers',
  31. when: answers => answers.e2e === 'nightwatch',
  32. type: `checkbox`,
  33. message: `Pick browsers to run end-to-end test on`,
  34. choices: [
  35. {
  36. name: `Chrome`,
  37. value: 'chrome',
  38. checked: true
  39. },
  40. {
  41. name: 'Firefox',
  42. value: 'firefox',
  43. // check the "Firefox" option if user has installed it
  44. checked: !!installedBrowsers.firefox
  45. }
  46. ]
  47. })
  48. cli.onPromptComplete((answers, options) => {
  49. if (answers.e2e === 'cypress') {
  50. options.plugins['@vue/cli-plugin-e2e-cypress'] = {}
  51. } else if (answers.e2e === 'nightwatch') {
  52. options.plugins['@vue/cli-plugin-e2e-nightwatch'] = {}
  53. }
  54. })
  55. }