mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-01-22 23:30:08 -06:00
test: add test-changed script
This commit is contained in:
@@ -5,7 +5,8 @@
|
||||
"packages/test/*"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "jest --env node",
|
||||
"test": "jest --env node --runInBand",
|
||||
"test-changed": "node scripts/testChanged.js",
|
||||
"posttest": "yarn clean",
|
||||
"lint": "eslint --fix packages/**/*.js packages/**/bin/* test/**/*.js",
|
||||
"clean": "rimraf packages/test/*",
|
||||
@@ -23,7 +24,8 @@
|
||||
"testPathIgnorePatterns": [
|
||||
"/template/",
|
||||
"/packages/test/",
|
||||
"/temp/"
|
||||
"/temp/",
|
||||
".*.helper.js"
|
||||
]
|
||||
},
|
||||
"lint-staged": {
|
||||
|
||||
21
scripts/testChanged.js
Normal file
21
scripts/testChanged.js
Normal file
@@ -0,0 +1,21 @@
|
||||
const execa = require('execa')
|
||||
|
||||
const additionalArgs = process.argv.slice(2)
|
||||
|
||||
;(async () => {
|
||||
// get modified files
|
||||
const { stdout } = await execa('git', ['ls-files', '--exclude-standard', '--modified', '--others'])
|
||||
const files = stdout.split('\n').filter(line => /\.js$/.test(line))
|
||||
|
||||
await execa('jest', [
|
||||
'--env', 'node',
|
||||
'--runInBand',
|
||||
...additionalArgs,
|
||||
'--findRelatedTests', ...files
|
||||
], {
|
||||
stdio: 'inherit'
|
||||
})
|
||||
})().catch(err => {
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
})
|
||||
Reference in New Issue
Block a user