An open API service indexing awesome lists of open source software.

https://github.com/agilecreativity/jsbdd-bootstrap


https://github.com/agilecreativity/jsbdd-bootstrap

Last synced: over 1 year ago
JSON representation

Awesome Lists containing this project

README

          

## README.md

The bootstrap script for working with JavaScript and NodeJS in BDD/TDD ways.

### Basic Usage

- Run the initial npm command

```shell
cd ~/codes
git clone git@github.com:agilecreativity/jsbdd-bootstrap.git
cd ~/codes/jssbdd-bootstrap
npm install
```

### Misc Tips

Since I am using the `nodenv` I usually run the following command first just to
make sure that I have everything setup to use the right version.

```
$nodenv --version
nodenv 0.3.3

$node --version
v0.10.37
```

I want to make sure that I use the latest version of node

```shell
$nodenv --versions
```

Which gives

```shell
v0.10
v0.10.28
v0.10.31
v0.10.37
v0.12
v0.12.0
v0.12.2
v0.6
v0.6.20
v0.8
v0.8.26
```

To install the latest version of node

```shell
$nodenv install v0.12.2
$nodenv rehash

$nodenv global v0.12.2
$nodenv rehash

# set our local version to the same if needed
$nodenv local v0.12.2
$nodenv rehash
```

The will generate the `package.json` which we can use to manage the dependency
for the project. This will generate the `package.json` file

```shell
$npm install mocha chai sinon sinon-chai coffee-script --save-dev
```

- Create the proper `.gitignore` file for the project

Tips I am using the command line that generated using [gitignore.io](http://www.gitignore.io)

e.g. `gi` service to create ignore file for a particular project type.

e.g. `gi node > .gitignore` which will produce the content like this

```
# Created by https://www.gitignore.io

### Node ###
# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
```

- Now install the `npm` modules for our testing

```
npm install chai sinon sinon-chai mocha --save-dev
```

- Now we need to generate the `package.json` using the `npm init` command

### Once the setup is done we can

```shell
npm run-script watch
```

### TODOs

Mocha comes with all of the following:

```
before
beforeEach
after
afterEach
```

- Use `grunt` for managing project
```
npm install -g grunt-cli
#...
npm install
grunt init:dev build:dev
grun test:server
```

- Use `brunch` to managing the project

### Links & Resources

- [Mocha](http://mochajs.org/) - the official Mocha site
- [CoffeeScript tutorials from TutsPlus](http://code.tutsplus.com/categories/coffeescript)
- [More Mocha and CoffeeScript testings from TutsPlus](http://code.tutsplus.com/tutorials/better-coffeescript-testing-with-mocha--net-24696)
- http://www.maori.geek.nz/post/testing_promises_in_node_js_with_mocha_chai_and_sinon

### Books
- [Web Development with MongoDB and Node.js](http://kroltech.com/2014/02/node-js-testing-with-mocha-chai-sinon-proxyquire/#.VSiqcWSqqko)
- [Learning Behavior-Driven-Development with JavaScript - Packtpub - 2015](http://packtpub.com/)
- http://webapplog.com/test-driven-development-in-node-js-with-mocha/