|
| 1 | +# Vue Test Utils Contributing Guide |
| 2 | + |
| 3 | +Hi! I’m really excited that you are interested in contributing to Vue Test Utils. Before submitting your contribution though, please make sure to take a moment and read through the following guidelines. |
| 4 | + |
| 5 | +- [Code of Conduct](https://github.com/vuejs/vue/blob/dev/.github/CODE_OF_CONDUCT.md) |
| 6 | +- [Issue Reporting Guidelines](#issue-reporting-guidelines) |
| 7 | +- [Pull Request Guidelines](#pull-request-guidelines) |
| 8 | +- [Development Setup](#development-setup) |
| 9 | +- [Project Structure](#project-structure) |
| 10 | + |
| 11 | +## Issue Reporting Guidelines |
| 12 | + |
| 13 | +- Always use [https://new-issue.vuejs.org/](https://new-issue.vuejs.org/) to create new issues. |
| 14 | + |
| 15 | +## Pull Request Guidelines |
| 16 | + |
| 17 | +- The `master` branch is basically just a snapshot of the latest stable release. All development should be done in dedicated branches. **Do not submit PRs against the `master` branch.** |
| 18 | + |
| 19 | +- Checkout a topic branch from the relevant branch, e.g. `dev`, and merge back against that branch. |
| 20 | + |
| 21 | +- Work in the `src` folder and **DO NOT** checkin `dist` in the commits. |
| 22 | + |
| 23 | +- It's OK to have multiple small commits as you work on the PR - we will let GitHub automatically squash it before merging. |
| 24 | + |
| 25 | +- Make sure `npm test` passes. (see [development setup](#development-setup)) |
| 26 | + |
| 27 | +- If adding new feature: |
| 28 | + - Add accompanying test case. |
| 29 | + - Provide convincing reason to add this feature. Ideally you should open a suggestion issue first and have it greenlighted before working on it. |
| 30 | + |
| 31 | +- If fixing a bug: |
| 32 | + - If you are resolving a special issue, add `(fix #xxxx[,#xxx])` (#xxxx is the issue id) in your PR title for a better release log, e.g. `update entities encoding/decoding (fix #3899)`. |
| 33 | + - Provide detailed description of the bug in the PR. Live demo preferred. |
| 34 | + - Add appropriate test coverage if applicable. |
| 35 | + |
| 36 | +## Development Setup |
| 37 | + |
| 38 | +You will need [Node.js](http://nodejs.org) **version 6+** |
| 39 | + |
| 40 | +Vue Test Utils is a monorepo. It contains a root package.json for running scripts across the project. The code is inside sepearte packages in the `packages` directory. The project uses [lerna](https://lernajs.io/) to manage the workspaces. |
| 41 | + |
| 42 | +After cloning the repo, run: |
| 43 | + |
| 44 | +``` bash |
| 45 | +$ yarn |
| 46 | +``` |
| 47 | + |
| 48 | +Or with npm: |
| 49 | + |
| 50 | +```bash |
| 51 | +npm i && npm run bootstrap |
| 52 | +``` |
| 53 | +### Commonly used NPM scripts |
| 54 | + |
| 55 | +``` bash |
| 56 | +# run unit tests with mocha-webpack |
| 57 | +$ npm run test:unit |
| 58 | + |
| 59 | +# run the full test suite, include linting / type checking |
| 60 | +$ npm test |
| 61 | +``` |
| 62 | + |
| 63 | +There are some other scripts available in the `scripts` section of the `package.json` file. |
| 64 | + |
| 65 | +The default test script will do the following: lint with ESLint -> type check with Flow -> unit tests. **Please make sure to have this pass successfully before submitting a PR.** Although the same tests will be run against your PR on the CI server, it is better to have it working locally beforehand. |
| 66 | + |
| 67 | +## Project Structure |
| 68 | + |
| 69 | +- **`docs`**: contains files used to generate https://vue-test-utils.vuejs.org/ with [GitBook](https://www.gitbook.com/). |
| 70 | + |
| 71 | +- **`flow`**: contains type declarations for [Flow](https://flowtype.org/). These declarations are loaded **globally** and you will see them used in type annotations in normal source code. |
| 72 | + |
| 73 | +- **`packages`**: contains the `test-utils` and `server-test-utils` public packages. Also contains private packages `shared` and `create-instance` wich are used by `test-utils` and `server-test-utils`. The codebase is written in ES2015 with [Flow](https://flowtype.org/) type annotations. |
| 74 | + |
| 75 | + - **`test-utils`**: the @vue/test-utils package. |
| 76 | + |
| 77 | + - **`dist`**: contains built files for distribution. Note this directory is only updated when a release happens; they do not reflect the latest changes in development branches. |
| 78 | + |
| 79 | + - **`server-test-utils`**: the @vue/server-test-utils package |
| 80 | + |
| 81 | + - **`dist`**: contains built files for distribution. Note this directory is only updated when a release happens; they do not reflect the latest changes in development branches. |
| 82 | + |
| 83 | + - **`create-instance`**: private package that creates an instance and applies mounting options. |
| 84 | + |
| 85 | + - **`shared`**: private package that contains utilities used by the other packzges. |
| 86 | + |
| 87 | +- **`scripts`**: contains build-related scripts and configuration files. In most cases you don't need to touch them. |
| 88 | + |
| 89 | +- **`test`**: contains all tests. The unit tests are written with [Mocha](https://mochajs.org/) and run with [Karma](http://karma-runner.github.io/0.13/index.html) and [mocha-webpack](http://zinserjan.github.io/mocha-webpack/), which compiles the code with webpack before running it in mocha. |
| 90 | + |
| 91 | +- **`types`**: contains TypeScript type definitions |
| 92 | + |
| 93 | + - **`test`**: type definitions tests |
0 commit comments