Skip to content

Commit

Permalink
test: add test-plugin script
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jan 14, 2018
1 parent aa87be0 commit e00f3f7
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,26 @@ cd test-app
yarn serve
```

### Testing Tips

The full test suite is rather slow, because it has a number of e2e tests that performs full webpack builds of actual projects. To limit the tests to only the plugin / files you are working on, you can use the `test-changed` script, which automatically runs only tests that are related to the files that have been modified/added since the last commit:

``` sh
yarn test-changed
```

Alternatively, you can run tests for a specific plugin (note this only matches files ending in `.spec.js` in the given plugin):

``` sh
yarn test-plugin pwa
```

Or, just specify your own regex:

``` sh
yarn test <fileRegex>
```

### Plugin Development

See [dedicated section in docs](https://github.com/vuejs/vue-cli/tree/next/docs/Plugin.md).
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"scripts": {
"test": "jest --env node --runInBand",
"test-changed": "node scripts/testChanged.js",
"test-plugin": "node scripts/testPlugin.js",
"posttest": "yarn clean",
"posttest-changed": "yarn clean",
"lint": "eslint --fix packages/**/*.js packages/**/bin/* test/**/*.js",
"clean": "rimraf packages/test/*",
"sync": "node scripts/syncDeps.js",
Expand Down
17 changes: 17 additions & 0 deletions scripts/testPlugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const execa = require('execa')

const plugins = process.argv.slice(2)
const regex = new RegExp(`.*cli-plugin-(${plugins.join('|')})/.*\\.spec\\.js$`)

;(async () => {
await execa('jest', [
'--env', 'node',
'--runInBand',
regex.toString().slice(1, -1)
], {
stdio: 'inherit'
})
})().catch(err => {
console.error(err)
process.exit(1)
})

0 comments on commit e00f3f7

Please sign in to comment.