1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-11 00:08:30 +01:00

Introduce jest as test-framework for gui code (react).

jest is somewhat documented here:
https://facebook.github.io/jest/

related to #61
This commit is contained in:
ivaosthu 2014-12-03 15:03:08 +01:00 committed by Ivar Conradi Østhus
parent 2f0cddd45b
commit fc42827641
3 changed files with 30 additions and 1 deletions

7
jest-preprocessor.js Normal file
View File

@ -0,0 +1,7 @@
// preprocessor.js
var ReactTools = require('react-tools');
module.exports = {
process: function(src) {
return ReactTools.transform(src);
}
};

View File

@ -25,7 +25,8 @@
"test-bamboo-ci": "mocha test test/*",
"coverage": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec",
"coverage-report": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
"postinstall": "npm run build"
"postinstall": "npm run build",
"jest": "jest"
},
"dependencies": {
"bluebird": "2.2.2",
@ -50,13 +51,20 @@
"chai": "1.9.1",
"coveralls": "^2.11.2",
"istanbul": "0.3.2",
"jest-cli": "^0.1.18",
"jshint": "2.5.2",
"mocha": "1.20.1",
"mocha-lcov-reporter": "0.0.1",
"mockery": "1.4.0",
"pre-commit": "0.0.9",
"react-tools": "^0.12.0",
"supertest": "0.13.0",
"supervisor": "0.6.0",
"xmlbuilder": "2.4.4"
},
"jest": {
"scriptPreprocessor": "<rootDir>/jest-preprocessor.js",
"unmockedModulePathPatterns": ["<rootDir>/node_modules/react"],
"moduleFileExtensions": ["jsx", "js"]
}
}

View File

@ -0,0 +1,14 @@
/** @jsx React.DOM */
jest.dontMock("../components/Menu");
var Menu = require("../components/Menu");
var React = require("react/addons");
var TestUtils = React.addons.TestUtils;
describe('Menu test', function () {
it('should include unleash in menu', function () {
var Compononent = TestUtils .renderIntoDocument(<Menu />);
expect(Compononent.getDOMNode().textContent).toMatch('unleash');
});
});