UNPKG

vue-cli-plugin-unit-jest-with-mode-support

Version:
34 lines (30 loc) 913 B
module.exports = api => { api.registerCommand('test:unit', { description: 'run unit tests with jest', usage: 'vue-cli-service test:unit [options] <regexForTestFiles>', options: { '--watch': 'run tests in watch mode' }, details: `All jest command line options are supported.\n` + `See https://facebook.github.io/jest/docs/en/cli.html for more details.` }, (_, rawArgv) => { // for @vue/babel-preset-app process.env.VUE_CLI_BABEL_TARGET_NODE = true process.env.VUE_CLI_BABEL_TRANSPILE_MODULES = true let modeIndex = -2; args = rawArgv.filter((a, i) => { if (i - 1 == modeIndex) return false if (a.startsWith("--mode=")) return false if (a.startsWith("--mode")) { modeIndex = i return false } return true }) require('jest').run(args) }) } module.exports.defaultModes = { 'test:unit': 'test' }