unit.js 896 B

12345678910111213141516171819202122232425262728293031323334353637
  1. module.exports = cli => {
  2. cli.injectFeature({
  3. name: 'Unit Testing',
  4. value: 'unit',
  5. short: 'Unit',
  6. description: 'Add a Unit Testing solution like Jest or Mocha',
  7. link: 'https://cli.vuejs.org/config/#unit-testing',
  8. plugins: ['unit-jest', 'unit-mocha']
  9. })
  10. cli.injectPrompt({
  11. name: 'unit',
  12. when: answers => answers.features.includes('unit'),
  13. type: 'list',
  14. message: 'Pick a unit testing solution:',
  15. choices: [
  16. {
  17. name: 'Mocha + Chai',
  18. value: 'mocha',
  19. short: 'Mocha'
  20. },
  21. {
  22. name: 'Jest',
  23. value: 'jest',
  24. short: 'Jest'
  25. }
  26. ]
  27. })
  28. cli.onPromptComplete((answers, options) => {
  29. if (answers.unit === 'mocha') {
  30. options.plugins['@vue/cli-plugin-unit-mocha'] = {}
  31. } else if (answers.unit === 'jest') {
  32. options.plugins['@vue/cli-plugin-unit-jest'] = {}
  33. }
  34. })
  35. }