Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tompascall/boilerplate-code-retreat
A minimal framework for node projects
https://github.com/tompascall/boilerplate-code-retreat
Last synced: about 1 month ago
JSON representation
A minimal framework for node projects
- Host: GitHub
- URL: https://github.com/tompascall/boilerplate-code-retreat
- Owner: tompascall
- Created: 2014-11-13T15:39:12.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2014-11-16T21:25:08.000Z (about 10 years ago)
- Last Synced: 2023-08-28T06:21:23.321Z (over 1 year ago)
- Language: JavaScript
- Size: 207 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
###Boilerplate for Global Day of Coderetreat
This project represents a minimal boilerplate code to start a Coderetreat project using Node.js, Mocha, Expect.js, Sinon.js with Grunt task automation.
####Prerequisities
- [Node.js](http://nodejs.org/)
- [Grunt](http://gruntjs.com/getting-started)####Installation
Clone the project, then run `npm install`.
####Grunt tasks
We have the following tasks:
- jshint to lint .js files
- mochacli to run testsWhen developing, run:
- `grunt watch` results in running grunt tasks automatically when a file is changed in the watched directory.
- `grunt test:dev` to lint your code and run your tests. The task stops if there's any failing test. The same happens if you run `grunt` without any arguments.
- `grunt test:all` to lint your code and run the test suite with all the tests, no matter if there's a failing one.
####Sample project
You can check the boilerplate by running `grunt` in the project folder. There is a sample test in the `test` directory, that tests a simple `sum()` function:
```js
// sample.module.spec.js'use strict';
var expect = require('expect.js');
var sum = require('../src/sample.module.js');describe('Sample test', function(){
it('should add arguments', function(){
expect(sum(1, 2, 3, 4, 5)).to.equal(1 + 2 + 3 + 4 + 5);
});
});describe('Sample stub test', function(){
it('returns the return value from the original function', function () {
var callback = sinon.stub().returns(1 + 2 + 3 + 4 + 5);
var proxy = sum(callback);expect(proxy()).to.equal(1 + 2 + 3 + 4 + 5);
});
});
```And there is a sample production code in `src` directory, that contains the tested function:
```js
// sample.module.js'use strict';
var sum = function(){
var args = Array.prototype.slice.call(arguments);
return args.reduce(function(previous, current){
return previous + current;
});
};module.exports = sum;
```####Cleaning up the boilerplate
You can clean up the boilerplate by running `grunt clean`. It will delete all files and subfolders in `src` and `test` folders. There is a copy of the sample files in the `sample` folder.
####Used packages
- Grunt.js for task automaton
- `grunt-contrib-jshint` for linting
- `grunt-newer` for running Grunt tasks on newer files only
- `grunt-contrib-watch`
- `grunt-mocha-cli` (Mocha testing framework for Grunt)
- `grunt-contrib-clean` (cleaning up the boilerplate)
- Expect.js as an assertion framework
- Sinon.js as a mocking tool####EditorConfig
EditorConfig is used to maintain consistent coding styles. There is an `.editorconfig` file in the project root directory, that defines the main styles.
You have [EditorConfig plugins](http://editorconfig.org/) for lots of editors.
As opening a file, EditorConfig plugins look for a file named `.editorconfig` in the directory of the opened file and in every parent directory. A search for `.editorconfig` files will stop if the root filepath is reached or an `.editorconfig` file with `root=true` is found.