|
1 | | -nodejs-tdd-boilerplate |
2 | | -====================== |
| 1 | +[](http://www.testspace.com) |
| 2 | +*** |
3 | 3 |
|
4 | | -# NodeJS TDD Boilerplate |
| 4 | +## JavaScript/Mocha sample for demonstrating Testspace based on the [nodejs-tdd-boilerplate](https://github.com/BryanDonovan/nodejs-tdd-boilerplate) |
5 | 5 |
|
6 | | -A basic boilerplate for NodeJS REST API applications that emphasizes code consistency and excellent test coverage. |
| 6 | +Sample demonstrates techniques for using Testspace with Javascript code and the [Mocha test framework](https://mochajs.org/) together with [Istanbul code coverage tool](https://gotwarlost.github.io/istanbul/). |
7 | 7 |
|
8 | | -## Features |
9 | 8 |
|
10 | | -* [mocha](https://github.com/visionmedia/mocha) test framework. |
11 | | -* [sinon](http://sinonjs.org) stubbing framework. |
12 | | -* [istanbul](https://github.com/yahoo/istanbul) test coverage framework. |
13 | | -* [jshint](http://jshint.com/) code linting. |
14 | | -* [restify](http://mcavage.github.com/node-restify/) REST framework. |
15 | | -* choice between make and [jake](https://github.com/mde/jake) build tool. |
16 | | -* choice of combined or separate servers for each 'app'. |
17 | | -* servers can run on multiple ports. |
| 9 | +*** |
| 10 | +Using Multiple Online CI Services: |
18 | 11 |
|
19 | | -## Planned |
20 | | -* Actual model implementation example instead of stubbed model. |
21 | 12 |
|
22 | | -## Setup |
| 13 | +*** |
| 14 | +Publising **Test Content** using www.testspace.com |
23 | 15 |
|
24 | | -Assuming you already have NodeJS 0.8.11 or higher installed: |
| 16 | +*** |
25 | 17 |
|
26 | | - git clone https://github.com/BryanDonovan/nodejs-tdd-boilerplate.git |
27 | | - cd nodejs-tdd-boilerplate |
28 | | - npm install . |
29 | | - make |
| 18 | +In order to run this sample you will need a host workstation with installed npm. |
30 | 19 |
|
31 | | -Note: to use `jake` you need to install it globally: |
| 20 | +<pre> |
| 21 | +npm install |
| 22 | +make lint test |
| 23 | +</pre> |
32 | 24 |
|
33 | | - npm install -g jake |
| 25 | +Publishing results example: |
34 | 26 |
|
35 | | -You can view available jake tasks with `jake -T`. |
| 27 | +<pre> |
| 28 | +curl -s https://testspace-client.s3.amazonaws.com/testspace-linux.tgz | sudo tar -zxvf- -C /usr/local/bin |
| 29 | +testspace checkstyle.xml [Tests]xunit.xml{test} coverage/cobertura-coverage.xm $TESTSPACE_TOKEN/$BRANCH_NAME |
| 30 | +</pre> |
36 | 31 |
|
37 | | -The `jake` or `make` command will run JSHint, all the mocha unit tests, and check the test coverage. To view the test coverage report, open coverage/lcov-report/index.html after running `make`. |
| 32 | +Checkout the [Space](http://samples.testspace.com/projects/javascript.mocha). |
38 | 33 |
|
39 | | -You can also run `make test` to just run the tests with coverage, `make test-cov` to run the tests and attempt to open the coverage report in your browser, and `make lint` to run JSHint. |
40 | | - |
41 | | -To run the acceptance tests (which are just mocha tests), first start the server: |
42 | | - |
43 | | - bin/start all |
44 | | - |
45 | | -Then: |
46 | | - |
47 | | - make test-acceptance |
48 | | -or: |
49 | | - |
50 | | - jake test:acceptance |
51 | | - |
52 | | -You can launch the sever on more than one port via `bin/launch`, for example: |
53 | | - |
54 | | - bin/launch users |
55 | | - |
56 | | -.. will launch the users app on two ports (specified in config.js). |
57 | | - |
58 | | -Then you can run the acceptance tests against either of those ports by specifying the PORT env variable: |
59 | | - |
60 | | - PORT=12100 make test-acceptance |
| 34 | +*** |
| 35 | +To replicate this sample: |
| 36 | + - Account at www.testspace.com. |
| 37 | + - CI Environment Variable called **TESTSPACE_TOKEN** required: |
| 38 | + - `TESTSPACE_TOKEN` = `[email protected]/my-project` |
| 39 | + - `credentials` set to `username:password` or your [access token](http://help.testspace.com/reference:client-reference#login-credentials). |
| 40 | + - `my-org-name.testspace.com/my-project` based on your *organization* (subdomain) and *project* names. |
0 commit comments