Skip to content

Commit cbce825

Browse files
committed
added Jest code coverage, updated README
1 parent 22d25e8 commit cbce825

File tree

5 files changed

+20
-13
lines changed

5 files changed

+20
-13
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ node_modules
44
tmp
55
bower_components
66
/dist/
7+
/coverage/

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
Example of [React](http://facebook.github.io/react/) + [Flow](http://flowtype.org/) types + [Reflux](https://www.npmjs.com/package/reflux) + [routing](https://github.com/rackt/react-router) + [ES6 with experimental ES7 syntax](https://babeljs.io/docs/usage/experimental/) + [Semantic-UI](http://semantic-ui.com/)
66

77
* All JavaScript files are transpiled with [Babel](https://babeljs.io/) library with enabled [experimental ES7 syntax](http://babeljs.io/docs/usage/transformers/#es7-experimental-).
8+
* The project support [Flow](http://flowtype.org/) type annotations
89
* For using experimental ES7 code in [Jest](http://facebook.github.io/jest/docs/tutorial-react.html) tests
910
* The workflow and communication between components is built using [Reflux](https://github.com/spoike/refluxjs), a slighty [improved](http://blog.krawaller.se/posts/reflux-refinement/) Flux paradigm.
1011
* Unit testing is provided by [Jest](https://facebook.github.io/jest/).
@@ -27,6 +28,11 @@ npm install
2728
```
2829
broccoli serve
2930
```
31+
or
32+
33+
```
34+
npm start
35+
```
3036

3137
* with additional [LiveReload](https://chrome.google.com/webstore/detail/livereload/jnihajbhpnppcggbcgedagnkighmdlei):
3238

@@ -50,16 +56,18 @@ Open `http://localhost:4200`
5056
BROCCOLI_ENV=production broccoli build dist
5157
```
5258

53-
Test:
59+
Test and code coverage:
5460

5561
```
5662
$ npm test
5763
```
5864

65+
You can see code coverage statistics at [http://localhost:8080/lcov-report/](http://localhost:8080/lcov-report/).
66+
5967
Currently just a simple example of using unit tests in React for files using ES6/ES7 syntax.
6068

6169
## Todo
6270
* replace Reflux with [nuclear-js](https://github.com/optimizely/nuclear-js)
63-
* Add examples of Flow types checking
71+
* Add examples of [Flow](http://flowtype.org/) types checking
6472
* Add more [prop validation](http://facebook.github.io/react/docs/reusable-components.html) examples
6573
* Add more unit tests showing [Jest](http://facebook.github.io/jest/) testing ES5/ES7 code with [Flow](http://flowtype.org/) types checking.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "react-es7",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "Example of using React + Flow types + Reflux + router + ES6 with experimental ES7 syntax + Jest + Semantic-UI",
55
"main": "src/index.js",
66
"scripts": {
7-
"test": "BABEL_JEST_STAGE=0 jest",
7+
"test": "BABEL_JEST_STAGE=0 jest --coverage",
88
"bundle": "broccoli build dist",
9-
"serve": "broccoli serve"
9+
"start": "broccoli serve"
1010
},
1111
"jest": {
1212
"scriptPreprocessor": "<rootDir>/node_modules/babel-jest",

src/__tests__/sum-test.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
jest.dontMock('../sum'); // or jest.autoMockOff();
1+
jest.dontMock('../lib/sum'); // or jest.autoMockOff();
22

3-
// cannot use es6 modules because
4-
// jest.dontMock & jest,autoMockOff()
5-
// do not understand ES6 modules
6-
const sum = require('../sum');
3+
// cannot use es6 modules syntax because
4+
// jest.dontMock & jest.autoMockOff()
5+
// do not understand ES6 modules yet
6+
const sum = require('../lib/sum');
77

88
describe('sum', function () {
9-
it('adds 1 + 2 to equal 3', function () {
10-
expect(sum(1, 2)).toBe(3);
11-
});
9+
it('adds 1 + 2 to equal 3', () => expect(sum(1, 2)).toBe(3))
1210
});
File renamed without changes.

0 commit comments

Comments
 (0)