mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-01-26 09:09:05 -06:00
layout unit tests
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
"precommit": "lint-staged"
|
||||
},
|
||||
"jest": {
|
||||
"testMatch": ["<rootDir>/test/**/*.js"],
|
||||
"testEnvironment": "node",
|
||||
"testPathIgnorePatterns": [
|
||||
"/node_modules/",
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
const path = require('path')
|
||||
|
||||
exports.ownDir = function (...args) {
|
||||
return path.join(__dirname, '../', ...args)
|
||||
}
|
||||
@@ -4,6 +4,14 @@ const { execSync } = require('child_process')
|
||||
const padStart = require('string.prototype.padstart')
|
||||
const { logWithSpinner, stopSpinner } = require('./spinner')
|
||||
|
||||
const wrapForTest = fn => {
|
||||
return (...args) => {
|
||||
if (!process.env.VUE_CLI_TEST) {
|
||||
return fn.apply(null, args)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const format = (label, msg) => {
|
||||
return msg.split('\n').map((line, i) => {
|
||||
return i === 0
|
||||
@@ -15,6 +23,8 @@ const format = (label, msg) => {
|
||||
exports.logWithSpinner = logWithSpinner
|
||||
exports.stopSpinner = stopSpinner
|
||||
|
||||
exports.log = msg => console.log(msg || '')
|
||||
|
||||
exports.info = msg => {
|
||||
console.log(format(chalk.bgBlue.black(' INFO '), msg))
|
||||
}
|
||||
@@ -27,7 +37,7 @@ exports.warn = msg => {
|
||||
console.warn(format(chalk.bgYellow.black(' WARN '), chalk.yellow(msg)))
|
||||
}
|
||||
|
||||
exports.error = (msg) => {
|
||||
exports.error = msg => {
|
||||
console.error(format(chalk.bgRed(' ERROR '), chalk.red(msg)))
|
||||
if (msg instanceof Error) {
|
||||
console.error(msg.stack)
|
||||
@@ -46,6 +56,11 @@ exports.clearConsole = title => {
|
||||
}
|
||||
}
|
||||
|
||||
// wrap all log utils for tests
|
||||
Object.keys(exports).forEach(key => {
|
||||
exports[key] = wrapForTest(exports[key])
|
||||
})
|
||||
|
||||
exports.hasYarn = (() => {
|
||||
try {
|
||||
execSync('yarnpkg --version', { stdio: 'ignore' })
|
||||
|
||||
0
packages/@vue/cli-test-utils/index.js
Normal file
0
packages/@vue/cli-test-utils/index.js
Normal file
@@ -19,6 +19,7 @@ const {
|
||||
} = require('./options')
|
||||
|
||||
const {
|
||||
log,
|
||||
hasGit,
|
||||
hasYarn,
|
||||
logWithSpinner,
|
||||
@@ -135,14 +136,14 @@ module.exports = class Creator {
|
||||
|
||||
// log instructions
|
||||
stopSpinner()
|
||||
console.log()
|
||||
console.log(`🎉 Successfully created project ${chalk.yellow(name)}.`)
|
||||
console.log(
|
||||
log()
|
||||
log(`🎉 Successfully created project ${chalk.yellow(name)}.`)
|
||||
log(
|
||||
`👉 Get started with the following commands:\n\n` +
|
||||
chalk.cyan(` ${chalk.gray('$')} cd ${name}\n`) +
|
||||
chalk.cyan(` ${chalk.gray('$')} ${options.packageManager === 'yarn' ? 'yarn dev' : 'npm run dev'}`)
|
||||
)
|
||||
console.log()
|
||||
log()
|
||||
}
|
||||
|
||||
resolveIntroPrompts () {
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
it('should pass', () => {
|
||||
expect(1).toBe(1)
|
||||
|
||||
})
|
||||
3
test/unit/Generator.js
Normal file
3
test/unit/Generator.js
Normal file
@@ -0,0 +1,3 @@
|
||||
it('should pass', () => {
|
||||
|
||||
})
|
||||
3
test/unit/GeneratorAPI.js
Normal file
3
test/unit/GeneratorAPI.js
Normal file
@@ -0,0 +1,3 @@
|
||||
it('should pass', () => {
|
||||
|
||||
})
|
||||
3
test/unit/PluginAPI.js
Normal file
3
test/unit/PluginAPI.js
Normal file
@@ -0,0 +1,3 @@
|
||||
it('should pass', () => {
|
||||
|
||||
})
|
||||
3
test/unit/PromptModuleAPI.js
Normal file
3
test/unit/PromptModuleAPI.js
Normal file
@@ -0,0 +1,3 @@
|
||||
it('should pass', () => {
|
||||
|
||||
})
|
||||
3
test/unit/Service.js
Normal file
3
test/unit/Service.js
Normal file
@@ -0,0 +1,3 @@
|
||||
it('should pass', () => {
|
||||
|
||||
})
|
||||
3
test/unit/options.js
Normal file
3
test/unit/options.js
Normal file
@@ -0,0 +1,3 @@
|
||||
it('should pass', () => {
|
||||
|
||||
})
|
||||
Reference in New Issue
Block a user