Skip to content

Instantly share code, notes, and snippets.

@tristanwietsma
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tristanwietsma/236b5201251fea96b640 to your computer and use it in GitHub Desktop.
Save tristanwietsma/236b5201251fea96b640 to your computer and use it in GitHub Desktop.
Jest Example
# Jest Example
This is directly from the jest website.
## Requirements
- node
- npm
## Install
```bash
git clone https://gist.github.com/236b5201251fea96b640.git
cd 236b5201251fea96b640
npm install
mkdir __tests__
mv sum-test.js __tests__/
```
## Run
```bash
npm test
```
{
"scripts" : {
"test" : "jest"
},
"devDependencies": {
"jest-cli": "0.4.0"
}
}
jest.dontMock('../sum');
describe('sum', function() {
it('adds 1 + 2 to equal 3', function() {
var sum = require('../sum');
expect(sum(1, 2)).toBe(3);
});
});
function sum(value1, value2) {
return value1 + value2;
}
module.exports = sum;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment