1 | # tape-watch
|
2 |
|
3 | > Rerun tape tests when files change
|
4 |
|
5 | tape-watch is an auto-test runner for [tape]. It will re-run your tests when any of the files in your project changes. This is better than using [watch][] or [nodemon][]: it will reload your tests in the same Node.js process, saving you precious startup time.
|
6 |
|
7 | [![Status](https://travis-ci.org/rstacruz/tape-watch.svg?branch=master)](https://travis-ci.org/rstacruz/tape-watch "See test builds")
|
8 |
|
9 | [nodemon]: https://www.npmjs.com/package/nodemon
|
10 | [watch]: https://www.npmjs.com/package/watch
|
11 |
|
12 | ## Usage
|
13 |
|
14 | Can happily live in your project (`--save-dev`) or globally (`-g`). I prefer global, since it's compatible with every project with [tape][] in it.
|
15 |
|
16 | ```
|
17 | npm install -g tape-watch
|
18 | ```
|
19 |
|
20 | [tape]: https://github.com/substack/tape
|
21 |
|
22 | ## Reference
|
23 |
|
24 | ```
|
25 | Usage:
|
26 | $ tape-watch <files> [options] -- [options for the test]
|
27 |
|
28 | Options:
|
29 | -p, --pipe PACKAGE pipe to this package
|
30 | -o, --out CMD output to this file/cmd
|
31 | -R, --refresh PACKAGE ensure this PACKAGE gets refreshed
|
32 | -r, --require PACKAGE require a PACKAGE before startup
|
33 | -1, --once only run once
|
34 | -w, --watch cancel out --once
|
35 | -c, --clear clear console between test runs
|
36 |
|
37 | Other options:
|
38 | -h, --help show usage information
|
39 | -v, --version print version info and exit
|
40 | ```
|
41 | Examples:
|
42 |
|
43 | ```sh
|
44 | tape-watch test/index.js
|
45 | tape-watch test/index.js -p tap-spec
|
46 | tape-watch test/index.js -o '| tap-spec --color'
|
47 |
|
48 | # ensure require('jquery') and require('react') always gets reevaluated
|
49 | tape-watch test/index.js -r jquery -r react
|
50 |
|
51 | # run all test files in test/
|
52 | tape-watch 'test/**/*.js'
|
53 | ```
|
54 |
|
55 | ## Using with Babel
|
56 |
|
57 | Use the `-r` *(--require)* flag with [babel-register](https://www.npmjs.com/package/babel-register).
|
58 |
|
59 | ```sh
|
60 | tape-watch -r babel-register
|
61 | ```
|
62 |
|
63 | Before you do this, of course, you'll need to install the requisite modules first.
|
64 |
|
65 | ```sh
|
66 | npm install --save-dev babel-register babel-preset-es2015
|
67 | ```
|
68 |
|
69 | ```js
|
70 | /* package.json */
|
71 | "babel": {
|
72 | "presets": ["es2015"]
|
73 | }
|
74 | ```
|
75 |
|
76 | ## Adding `npm test`
|
77 |
|
78 | Add this to your `package.json`:
|
79 |
|
80 | ```js
|
81 | "scripts": {
|
82 | "test": "tape-watch -1 test/*"
|
83 | }
|
84 | ```
|
85 |
|
86 | You can now run tests with `npm test`, or make it auto-run with `npm test -- --watch`.
|
87 |
|
88 | ## Also see
|
89 |
|
90 | - [tape-growl](https://www.npmjs.com/package/tape-growl) for notifications on macOS
|
91 | - [tape-plus](https://www.npmjs.com/package/tape-plus) for grouping tape tests
|
92 |
|
93 | ## Thanks
|
94 |
|
95 | **tape-watch** © 2016+, Rico Sta. Cruz. Released under the [MIT] License.<br>
|
96 | Authored and maintained by Rico Sta. Cruz with help from contributors ([list][contributors]).
|
97 |
|
98 | > [ricostacruz.com](http://ricostacruz.com) ·
|
99 | > GitHub [@rstacruz](https://github.com/rstacruz) ·
|
100 | > Twitter [@rstacruz](https://twitter.com/rstacruz)
|
101 |
|
102 | [MIT]: http://mit-license.org/
|
103 | [contributors]: http://github.com/rstacruz/tape-watch/contributors
|