commit c3c067e7af077ae00d948d579f7e714406d6f937
parent fba71412a489e9ce4297db0afba0a8f33fffc211
Author: Konstantin Tarkus <hello@tarkus.me>
Date: Wed, 17 Sep 2014 17:55:28 +0400
Add a unit test sample with Karma
Diffstat:
5 files changed, 72 insertions(+), 3 deletions(-)
diff --git a/config/karma.js b/config/karma.js
@@ -0,0 +1,44 @@
+var webpackConfig = require('./webpack.js')(/* release */ false);
+
+module.exports = function (config) {
+ config.set({
+
+ basePath : '../',
+
+ files : [
+ 'src/**/*Spec.jsx'
+ ],
+
+ preprocessors: {
+ 'src/**/*Spec.jsx': ['webpack']
+ },
+
+ webpack: {
+ cache: true,
+ module: {
+ loaders: webpackConfig.module.loaders
+ }
+ },
+
+ webpackServer: {
+ stats: {
+ colors: true
+ }
+ },
+
+ autoWatch : true,
+
+ frameworks: ['jasmine'],
+
+ browsers : ['Chrome'],
+
+ plugins : [
+ 'karma-chrome-launcher',
+ 'karma-firefox-launcher',
+ 'karma-phantomjs-launcher',
+ 'karma-jasmine',
+ 'karma-webpack'
+ ]
+
+ });
+};
diff --git a/config/webpack.config.js b/config/webpack.js
diff --git a/gulpfile.js b/gulpfile.js
@@ -113,7 +113,7 @@ gulp.task('styles', function () {
// Bundle
gulp.task('bundle', function (cb) {
var started = false;
- var config = require('./config/webpack.config.js')(RELEASE);
+ var config = require('./config/webpack.js')(RELEASE);
var bundler = webpack(config);
function bundle (err, stats) {
diff --git a/package.json b/package.json
@@ -4,6 +4,7 @@
"version": "0.0.0",
"description": "Facebook React Starter Kit",
"repository": "https://github.com/kriasoft/react-starter-kit",
+ "license": "MIT",
"dependencies": {
"bootstrap": "^3.2.0",
"react": "^0.11.2",
@@ -34,15 +35,25 @@
"jshint-stylish": "^0.4.0",
"jsx-loader": "^0.11.0",
"karma": "^0.12.23",
+ "karma-chrome-launcher": "^0.1.4",
+ "karma-firefox-launcher": "^0.1.3",
+ "karma-jasmine": "^0.1.5",
+ "karma-phantomjs-launcher": "^0.1.4",
+ "karma-webpack": "^1.2.2",
+ "karma-webpack-plugin": "^1.0.0",
"merge-stream": "^0.1.5",
"minimist": "^1.1.0",
"protractor": "^1.2.0",
"rimraf": "^2.2.8",
"run-sequence": "^0.3.6",
"url-loader": "^0.5.5",
- "webpack": "^1.4.0-beta9"
+ "webpack": "^1.4.0-beta9",
+ "webpack-dev-server": "^1.6.4"
},
"scripts": {
- "test": "echo \"Error: no test specified\" && exit 1"
+ "prestart": "npm install",
+ "start": "gulp",
+ "pretest": "npm install",
+ "test": "karma start ./config/karma.js --single-run"
}
}
diff --git a/src/components/NavbarSpec.jsx b/src/components/NavbarSpec.jsx
@@ -0,0 +1,14 @@
+'use strict';
+
+describe('Navbar', () => {
+ var Navbar, component;
+
+ beforeEach(() => {
+ Navbar = require('./Navbar.jsx');
+ component = Navbar();
+ });
+
+ it('should create a new instance of Navbar', () => {
+ expect(component).toBeDefined();
+ });
+});