[tansaku@Samuels-MBP:~/tmp ]$
→ mkdir node_tests_rep4
[tansaku@Samuels-MBP:~/tmp ]$
→ cd node_tests_rep4/
[tansaku@Samuels-MBP:~/tmp/node_tests_rep4 ]$
→ 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_rep4)
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_rep4/package.json:
{
"name": "node_tests_rep4",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "mocha test/**/*.js"
},
"author": "",
"license": "ISC"
}
Is this ok? (yes)
[tansaku@Samuels-MBP:~/tmp/node_tests_rep4 ]$
→ npm install mocha chai
[email protected] /Users/tansaku/tmp/node_tests_rep4
├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ └── [email protected]
└─┬ [email protected]
├── [email protected]
├─┬ [email protected]
│ └── [email protected]
├─┬ [email protected]
│ └── [email protected]
├── [email protected]
├── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ └── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ └── [email protected]
├─┬ [email protected]
│ └── [email protected]
└─┬ [email protected]
└── [email protected]
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
[tansaku@Samuels-MBP:~/tmp/node_tests_rep4 ]$
→ mkdir lib
[tansaku@Samuels-MBP:~/tmp/node_tests_rep4 ]$
→ mkdir test
[tansaku@Samuels-MBP:~/tmp/node_tests_rep4 ]$
→ touch test/test_spec.js
[tansaku@Samuels-MBP:~/tmp/node_tests_rep4 ]$
→ touch lib/test.js
[tansaku@Samuels-MBP:~/tmp/node_tests_rep4 ]$
→ subl .
[tansaku@Samuels-MBP:~/tmp/node_tests_rep4 ]$
→ npm test
> [email protected] test /Users/tansaku/tmp/node_tests_rep4
> mocha test/**/*.js
/Users/tansaku/tmp/node_tests_rep4/test/test_spec.js:7
}
^
SyntaxError: missing ) after argument list
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at /Users/tansaku/tmp/node_tests_rep4/node_modules/mocha/lib/mocha.js:231:27
at Array.forEach (native)
at Mocha.loadFiles (/Users/tansaku/tmp/node_tests_rep4/node_modules/mocha/lib/mocha.js:228:14)
at Mocha.run (/Users/tansaku/tmp/node_tests_rep4/node_modules/mocha/lib/mocha.js:514:10)
at Object.<anonymous> (/Users/tansaku/tmp/node_tests_rep4/node_modules/mocha/bin/_mocha:480:18)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:389:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:504:3
npm ERR! Test failed. See above for more details.
[tansaku@Samuels-MBP:~/tmp/node_tests_rep4 ]$
→ npm test
> [email protected] test /Users/tansaku/tmp/node_tests_rep4
> mocha test/**/*.js
athletic reps
1) gets less painful
0 passing (13ms)
1 failing
1) athletic reps gets less painful:
AssertionError: expected 'more' to equal 'less'
+ expected - actual
-more
+less
at Context.it (test/test_spec.js:6:21)
npm ERR! Test failed. See above for more details.
[tansaku@Samuels-MBP:~/tmp/node_tests_rep4 ]$
→ npm test
> [email protected] test /Users/tansaku/tmp/node_tests_rep4
> mocha test/**/*.js
athletic reps
✓ gets less painful
1 passing (7ms)
[tansaku@Samuels-MBP:~/tmp/node_tests_rep4 ]$
→ npm install standardjs
npm ERR! Darwin 16.7.0
npm ERR! argv "/Users/tansaku/.nvm/versions/node/v6.11.2/bin/node" "/Users/tansaku/.nvm/versions/node/v6.11.2/bin/npm" "install" "standardjs"
npm ERR! node v6.11.2
npm ERR! npm v3.10.10
npm ERR! code E404
npm ERR! 404 Registry returned 404 for GET on https://registry.npmjs.org/standardjs
npm ERR! 404
npm ERR! 404 'standardjs' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/tansaku/tmp/node_tests_rep4/npm-debug.log
[tansaku@Samuels-MBP:~/tmp/node_tests_rep4 ]$
→ npm install standard --save-dev
[email protected] /Users/tansaku/tmp/node_tests_rep4
└─┬ [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ └── [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ ├── [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └─┬ [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ ├─┬ [email protected]
│ │ │ │ │ └── [email protected]
│ │ │ │ └── [email protected]
│ │ │ ├── [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ └── [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ ├─┬ [email protected]
│ │ │ │ └── [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ └─┬ [email protected]
│ │ ├── [email protected]
│ │ └─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ └─┬ [email protected]
│ └── [email protected]
├── [email protected]
├── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ └─┬ [email protected]
│ └─┬ [email protected]
│ ├── [email protected]
│ └─┬ [email protected]
│ └── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ └── [email protected]
├── [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ ├─┬ [email protected]
│ │ │ └── [email protected]
│ │ └─┬ [email protected]
│ │ ├─┬ [email protected]
│ │ │ ├── [email protected]
│ │ │ └── [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ └─┬ [email protected]
│ └── [email protected]
├── [email protected]
└─┬ [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ └── [email protected]
├── [email protected]
├── [email protected]
└─┬ [email protected]
├─┬ [email protected]
│ └─┬ [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ └── [email protected]
└─┬ [email protected]
├─┬ [email protected]
│ └─┬ [email protected]
│ └── [email protected]
└── [email protected]
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
[tansaku@Samuels-MBP:~/tmp/node_tests_rep4 ]$
→ npm install chai mocha --save-dev
[email protected] /Users/tansaku/tmp/node_tests_rep4
├── [email protected]
└── [email protected]
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
[tansaku@Samuels-MBP:~/tmp/node_tests_rep4 ]$
→ standard --fix
-bash: standard: command not found
[tansaku@Samuels-MBP:~/tmp/node_tests_rep4 ]$
→ ./node_modules/.bin/standard
standard: Use JavaScript Standard Style (https://standardjs.com)
standard: Run `standard --fix` to automatically fix some problems.
/Users/tansaku/tmp/node_tests_rep4/lib/test.js:3:22: Newline required at end of file but not found.
/Users/tansaku/tmp/node_tests_rep4/test/test_spec.js:4:1: 'describe' is not defined.
/Users/tansaku/tmp/node_tests_rep4/test/test_spec.js:4:25: A space is required after ','.
/Users/tansaku/tmp/node_tests_rep4/test/test_spec.js:4:27: Missing space before =>.
/Users/tansaku/tmp/node_tests_rep4/test/test_spec.js:4:30: Missing space after =>.
/Users/tansaku/tmp/node_tests_rep4/test/test_spec.js:5:3: 'it' is not defined.
/Users/tansaku/tmp/node_tests_rep4/test/test_spec.js:5:28: Missing space before =>.
/Users/tansaku/tmp/node_tests_rep4/test/test_spec.js:5:31: Missing space after =>.
/Users/tansaku/tmp/node_tests_rep4/test/test_spec.js:8:3: Newline required at end of file but not found.
[tansaku@Samuels-MBP:~/tmp/node_tests_rep4 ]$
→ ./node_modules/.bin/standard --fix
standard: Use JavaScript Standard Style (https://standardjs.com)
/Users/tansaku/tmp/node_tests_rep4/test/test_spec.js:4:1: 'describe' is not defined.
/Users/tansaku/tmp/node_tests_rep4/test/test_spec.js:5:3: 'it' is not defined.
[tansaku@Samuels-MBP:~/tmp/node_tests_rep4 ]$
→ ./node_modules/.bin/standard --fix
[tansaku@Samuels-MBP:~/tmp/node_tests_rep4 ]$
with
var expect = require('chai').expect
var pain = require('../lib/test')
describe('athletic reps', () => {
it('gets less painful', () => {
expect(pain).to.equal('less')
})
})and
var pain = 'less'
module.exports = pain