Skip to content

Commit c7bd816

Browse files
committed
sample updates to testspace
1 parent 2ad8033 commit c7bd816

File tree

9 files changed

+89
-56
lines changed

9 files changed

+89
-56
lines changed

.c9build.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
# Build
4+
npm install
5+
6+
# Analysis and Test
7+
make lint test
8+
9+
# Publish
10+
curl -s https://testspace-client.s3.amazonaws.com/testspace-linux.tgz | sudo tar -zxvf- -C /usr/local/bin
11+
testspace checkstyle.xml [Tests]xunit.xml{test} coverage/cobertura-coverage.xml master.c9

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ coverage
33
log/*.log
44
tmp/*.*
55
test/support/tmp/*.js
6+
7+
checkstyle.xml
8+
xunit.xml

.travis.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
language: node_js
2+
node_js:
3+
- "4.0"
4+
5+
before_script:
6+
- npm install
7+
8+
script:
9+
- make lint test
10+
11+
after_script:
12+
- curl -s https://testspace-client.s3.amazonaws.com/testspace-linux.tgz | sudo tar -zxvf- -C /usr/local/bin
13+
- testspace checkstyle.xml [Tests]xunit.xml{test} coverage/cobertura-coverage.xml $TESTSPACE_TOKEN/${TRAVIS_BRANCH}#travis.Build.${TRAVIS_BUILD_NUMBER}

Makefile

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,15 @@ cover:
1010
$(ISTANBUL) cover test/run.js
1111

1212
check-coverage:
13-
$(ISTANBUL) check-coverage $(COVERAGE_OPTS)
13+
$(ISTANBUL) report cobertura
1414

1515
test: cover check-coverage
1616

17-
18-
test-cov: cover check-coverage
19-
open coverage/lcov-report/index.html
20-
2117
test-acceptance:
2218
test/run.js -T acceptance
2319

2420
lint:
25-
./node_modules/.bin/jshint ./lib --config $(BASE)/.jshintrc && \
26-
./node_modules/.bin/jshint ./test --config $(BASE)/.jshintrc
21+
./node_modules/.bin/jshint ./lib ./test --reporter=node_modules/jshint-checkstyle-file-reporter --config $(BASE)/.jshintrc
2722

2823

2924
.PHONY: test

README.md

Lines changed: 27 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,40 @@
1-
nodejs-tdd-boilerplate
2-
======================
1+
[![Testspace](http://www.testspace.com/public/img/testspace_logo.png)](http://www.testspace.com)
2+
***
33

4-
# NodeJS TDD Boilerplate
4+
## JavaScript/Mocha sample for demonstrating Testspace based on the [nodejs-tdd-boilerplate](https://github.com/BryanDonovan/nodejs-tdd-boilerplate)
55

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/).
77

8-
## Features
98

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:
1811

19-
## Planned
20-
* Actual model implementation example instead of stubbed model.
2112

22-
## Setup
13+
***
14+
Publising **Test Content** using www.testspace.com
2315

24-
Assuming you already have NodeJS 0.8.11 or higher installed:
16+
***
2517

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.
3019

31-
Note: to use `jake` you need to install it globally:
20+
<pre>
21+
npm install
22+
make lint test
23+
</pre>
3224

33-
npm install -g jake
25+
Publishing results example:
3426

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>
3631

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).
3833

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.

circle.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
machine:
2+
node:
3+
version: 4.0
4+
5+
test:
6+
override:
7+
- npm install
8+
- make lint test
9+
10+
post:
11+
- curl -s https://testspace-client.s3.amazonaws.com/testspace-linux.tgz | sudo tar -zxvf- -C /usr/local/bin
12+
- testspace checkstyle.xml [Tests]xunit.xml{test} coverage/cobertura-coverage.xml $TESTSPACE_TOKEN/${CIRCLE_BRANCH}#circle.Build.${CIRCLE_BUILD_NUM}

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@
1818
"settings": "0.1.1"
1919
},
2020
"devDependencies": {
21+
"Faker": "^0.7.2",
2122
"faker": "3.0.1",
2223
"istanbul": "0.4.2",
2324
"jshint": "2.9.1",
25+
"jshint-checkstyle-file-reporter": "0.0.1",
2426
"mocha": "2.4.5",
25-
"sinon": "1.17.3"
27+
"sinon": "1.17.3",
28+
"xunit-file": "^1.0.0"
2629
},
2730
"repository": {
2831
"type": "git",

shippable.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
language: node_js
2+
3+
node_js:
4+
- "4.0"
5+
6+
env:
7+
global:
8+
- secure: a9cYRKZdEIwS+F1qiz5RvUAOv/sC4tUtv4gtvkiMlPhAvLpDwN/HY4TvCgvJoFRTEy/tbqJWrT58kxzKiojo5N3Fz9L30V7IWzlT2v9NTBcUp7EJ+3nz3cReH4UNCKZCHJJ+tOLQqermycrDIiQWmLB5YycTvHtZf31QxNGPtg9xGG3UL7F/X+5FrvcDi8zuHQZA5Ndjn4TDiN7RDXcZmKmu8KKbZMaA6tSe3C1i3QBvMoXS5R8nsBTfjkHPOkoYwdV87+5WVghnKSc5wkgFSgzsBMEdWNkyE7O/mN07AM/bNLQZdGh9NEozfT6LYTiLXrV55T6nsHdr92ioLLVcmA==
9+
10+
script:
11+
- npm install
12+
- make lint test
13+
14+
after_script:
15+
- curl -s https://testspace-client.s3.amazonaws.com/testspace-linux.tgz | sudo tar -zxvf- -C /usr/local/bin
16+
- testspace checkstyle.xml [Tests]xunit.xml{test} coverage/cobertura-coverage.xml $TESTSPACE_TOKEN/${BRANCH}#ship.Build.${BUILD_NUMBER}

test/run.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var walk_dir = require('./support/walk_dir');
88

99
var argv = optimist
1010
.usage("Usage: $0 -t [types] --reporter [reporter] --timeout [timeout]")
11-
.default({types: 'unit,functional', reporter: 'spec', timeout: 6000})
11+
.default({types: 'unit,functional', reporter: 'xunit-file', timeout: 6000})
1212
.describe('types', 'The types of tests to run, separated by commas. E.g., unit,functional,acceptance')
1313
.describe('reporter', 'The mocha test reporter to use.')
1414
.describe('timeout', 'The mocha timeout to use per test (ms).')

0 commit comments

Comments
 (0)