[tansaku@Samuels-MBP:~/Documents/Github ]$
→ cd ~/tmp
[tansaku@Samuels-MBP:~/tmp ]$
→ mkdir node_tests_rep1
[tansaku@Samuels-MBP:~/tmp ]$
→ cd node_tests_rep1/
[tansaku@Samuels-MBP:~/tmp/node_tests_rep1 ]$
→ npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.
See `npm help json` for definitive documentation on these fields
and exactly what they do.
Use `npm install <pkg> --save` afterwards to install a package and
save it as a dependency in the package.json file.
Press ^C at any time to quit.
name: (node_tests_rep1)
version: (1.0.0)
description:
entry point: (index.js)
test command: mocha test/**/*.js
git repository:
keywords:
author:
license: (ISC)
About to write to /Users/tansaku/tmp/node_tests_rep1/package.json:
{
"name": "node_tests_rep1",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "mocha test/**/*.js"
},
"author": "",
"license": "ISC"
}
Is this ok? (yes) yes
[tansaku@Samuels-MBP:~/tmp/node_tests_rep1 ]$
→ npm install --save-dev
npm WARN node_tests_rep1@1.0.0 No description
npm WARN node_tests_rep1@1.0.0 No repository field.
[tansaku@Samuels-MBP:~/tmp/node_tests_rep1 ]$
→ npm install --save-dev mocha chai
node_tests_rep1@1.0.0 /Users/tansaku/tmp/node_tests_rep1
├─┬ chai@4.1.2
│ ├── assertion-error@1.0.2
│ ├── check-error@1.0.2
│ ├── deep-eql@3.0.1
│ ├── get-func-name@2.0.0
│ ├── pathval@1.1.0
│ └── type-detect@4.0.3
└─┬ mocha@3.5.0
├── browser-stdout@1.3.0
├─┬ commander@2.9.0
│ └── graceful-readlink@1.0.1
├─┬ debug@2.6.8
│ └── ms@2.0.0
├── diff@3.2.0
├── escape-string-regexp@1.0.5
├─┬ glob@7.1.1
│ ├── fs.realpath@1.0.0
│ ├─┬ inflight@1.0.6
│ │ └── wrappy@1.0.2
│ ├── inherits@2.0.3
│ ├─┬ minimatch@3.0.4
│ │ └─┬ brace-expansion@1.1.8
│ │ ├── balanced-match@1.0.0
│ │ └── concat-map@0.0.1
│ ├── once@1.4.0
│ └── path-is-absolute@1.0.1
├── growl@1.9.2
├── json3@3.3.2
├─┬ lodash.create@3.1.1
│ ├─┬ lodash._baseassign@3.2.0
│ │ ├── lodash._basecopy@3.0.1
│ │ └─┬ lodash.keys@3.1.2
│ │ ├── lodash._getnative@3.9.1
│ │ ├── lodash.isarguments@3.1.0
│ │ └── lodash.isarray@3.0.4
│ ├── lodash._basecreate@3.0.3
│ └── lodash._isiterateecall@3.0.9
├─┬ mkdirp@0.5.1
│ └── minimist@0.0.8
└─┬ supports-color@3.1.2
└── has-flag@1.0.0
npm WARN node_tests_rep1@1.0.0 No description
npm WARN node_tests_rep1@1.0.0 No repository field.
[tansaku@Samuels-MBP:~/tmp/node_tests_rep1 ]$
→ mkdir test
[tansaku@Samuels-MBP:~/tmp/node_tests_rep1 ]$
→ touch test/test_spec.js
[tansaku@Samuels-MBP:~/tmp/node_tests_rep1 ]$
→ subl .
[tansaku@Samuels-MBP:~/tmp/node_tests_rep1 ]$
→ npm test
> node_tests_rep1@1.0.0 test /Users/tansaku/tmp/node_tests_rep1
> mocha test/**/*.js
Athletic Rep
✓ should get less and less painful
1 passing (6ms)
[tansaku@Samuels-MBP:~/tmp/node_tests_rep1 ]$
→ mkdir lib
[tansaku@Samuels-MBP:~/tmp/node_tests_rep1 ]$
→ touch lib/test.js
[tansaku@Samuels-MBP:~/tmp/node_tests_rep1 ]$
→ mkdir lib
mkdir: lib: File exists
[tansaku@Samuels-MBP:~/tmp/node_tests_rep1 ]$
→ npm test
> node_tests_rep1@1.0.0 test /Users/tansaku/tmp/node_tests_rep1
> mocha test/**/*.js
Athletic Rep
✓ should get less and less painful
1 passing (7ms)
Elapsed time four minutes. No errors and following code stamped out from memory:
var expect = require('chai').expect;
const pain = require('../lib/test')
describe('Athletic Rep', function(){
it('should get less and less painful', function(){
expect(pain).to.equal('less');
})
})
const pain = 'less';
module.exports = pain;