Skip to content

Commit

Permalink
Merge branch 'jbinto-karma-chrome' into v3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mxstbr committed Jan 25, 2016
2 parents 0951e7f + 7e6fdb0 commit 6617ff4
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 21 deletions.
13 changes: 10 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
language: node_js
sudo: true
node_js:
- "5"
- "4"
- "0.10"
- "5.0"
script: npm run build
before_install:
- export CHROME_BIN=/usr/bin/google-chrome
- export DISPLAY=:99.0
- sudo apt-get update
- sudo apt-get install -y libappindicator1 fonts-liberation
- wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
- sudo dpkg -i google-chrome*.deb
- sh -e /etc/init.d/xvfb start
notifications:
email:
on_failure: change
6 changes: 3 additions & 3 deletions app/components/Img/Img.test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import Img from './index';

import { expect } from 'chai';
import expect from 'expect';
import { shallow } from 'enzyme';
import React from 'react';

describe('<Img />', () => {
it('should render an <img> tag', () => {
const renderedComponent = shallow(<Img src="test.png" alt="test" />);
expect(renderedComponent).to.have.tagName('img');
expect(renderedComponent.find('img').length).toEqual(1);
});

it('should have an alt attribute', () => {
const renderedComponent = shallow(<Img src="test.png" alt="test" />);
expect(renderedComponent).to.have.attr('alt', 'test');
expect(renderedComponent.prop('alt')).toEqual('test');
});
});
4 changes: 1 addition & 3 deletions app/containers/HomePage/tests/actions.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import expect from 'expect';
import rewire from 'rewire';

const AppActions = rewire('../actions');
import AppActions from '../actions';
const changeOwnerName = AppActions.__get__('changeOwnerName');
const changeProjectName = AppActions.__get__('changeProjectName');
import { CHANGE_OWNER_NAME, CHANGE_PROJECT_NAME } from '../constants';
Expand Down
4 changes: 1 addition & 3 deletions app/containers/HomePage/tests/reducer.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import expect from 'expect';
import rewire from 'rewire';
import * as constants from '../constants';
import homeReducer from '../reducer';

const rewiredhomeReducer = rewire('../reducer');
const initialState = rewiredhomeReducer.__get__('initialState');
const initialState = homeReducer.__get__('initialState');

// Test Reducer
describe('defaultReducer', () => {
Expand Down
38 changes: 38 additions & 0 deletions karma.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
var path = require('path');
var webpackConfig = require('./webpack/webpack.test.babel');

module.exports = function(config) {
config.set({
frameworks: ['mocha'],
reporters: ['mocha'],

browsers: process.env.TRAVIS
? ['ChromeTravis']
: ['Chrome'],

autoWatch: process.env.TRAVIS ? false : true,
singleRun: process.env.TRAVIS ? true : false,

files: [
'app/**/*.test.js'
],

preprocessors: {
['app/**/*.test.js']: ['webpack', 'sourcemap'],
},

webpack: webpackConfig,

// make Webpack bundle generation quiet
webpackMiddleware: {
noInfo: true
},

customLaunchers: {
ChromeTravis: {
base: 'Chrome',
flags: ['--no-sandbox']
}
}
});
};
16 changes: 11 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@
"babel-eslint": "^5.0.0-beta6",
"babel-loader": "^6.2.1",
"babel-plugin-react-transform": "^2.0.0",
"babel-plugin-rewire": "^1.0.0-beta-5",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"babel-preset-stage-2": "^6.3.13",
"chai": "^3.4.1",
"chai-enzyme": "^0.2.2",
"chalk": "^1.1.1",
"cheerio": "^0.19.0",
"css-loader": "^0.23.1",
Expand All @@ -41,9 +40,16 @@
"html-webpack-plugin": "^2.7.1",
"ip": "^1.1.0",
"json-loader": "^0.5.4",
"karma": "^0.13.19",
"karma-chrome-launcher": "^0.2.2",
"karma-mocha": "^0.2.1",
"karma-mocha-reporter": "^1.1.5",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^1.7.0",
"lint-staged": "^0.1.1",
"mocha": "^2.3.4",
"ngrok": "^0.2.2",
"null-loader": "^0.1.1",
"object.assign": "^4.0.3",
"offline-plugin": "^2.0.2",
"postcss-cssnext": "^2.4.0",
Expand All @@ -53,7 +59,6 @@
"psi": "^2.0.2",
"react-addons-test-utils": "^0.14.6",
"react-transform-hmr": "^1.0.1",
"rewire": "^2.5.1",
"style-loader": "^0.13.0",
"url-loader": "^0.5.7",
"webpack": "^1.12.11",
Expand All @@ -67,8 +72,9 @@
"lint": "eslint .",
"lint:staged": "eslint-staged",
"pretest": "npm run lint",
"test": "NODE_ENV=test mocha --compilers js:babel-core/register,css:css-modules-require-hook --require ./webpack/testHelper.js --recursive 'app/**/*.test.js'",
"test:watch": "NODE_ENV=test npm test -- --watch",
"test": "NODE_ENV=test karma start karma.config.js",
"test:mocha": "NODE_ENV=test mocha --compilers js:babel-core/register,css:css-modules-require-hook --require ./webpack/testHelper.js --recursive 'app/**/*.test.js'",
"test:mocha:watch": "NODE_ENV=test npm test -- --watch",
"start": "NODE_ENV=development node webpack/server.dev.js",
"prebuild": "npm run test",
"build": "NODE_ENV=production webpack --config webpack/webpack.prod.babel.js --progress --colors -p",
Expand Down
4 changes: 0 additions & 4 deletions webpack/testHelper.js

This file was deleted.

50 changes: 50 additions & 0 deletions webpack/webpack.test.babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* TEST WEBPACK CONFIGURATION
*/

module.exports = {
devtool: 'inline-source-map',
module: {
// Some libraries don't like being run through babel.
// If they gripe, put them here.
noParse: [
/node_modules\/sinon/,
/node_modules\/acorn/,
],
loaders: [
{ test: /\.json$/, loader: 'json-loader' },
{ test: /\.css$/, loader: 'null-loader' },
{ test: /\.js$/,
loader: 'babel',
exclude: [/node_modules/],
query: {
plugins: ['babel-plugin-rewire']
}
},
]
},
// Some node_modules pull in Node-specific dependencies.
// Since we're running in a browser we have to stub them out. See:
// https://webpack.github.io/docs/configuration.html#node
// https://github.com/webpack/node-libs-browser/tree/master/mock
// https://github.com/webpack/jade-loader/issues/8#issuecomment-55568520
node: {
fs: 'empty',
child_process: 'empty',
net: 'empty',
tls: 'empty',
},
// required for enzyme to work properly
externals: {
jsdom: 'window',
cheerio: 'window',
'react/lib/ExecutionEnvironment': true,
'react/lib/ReactContext': 'window'
},
resolve: {
alias: {
// required for enzyme to work properly
sinon: 'sinon/pkg/sinon'
},
},
};

0 comments on commit 6617ff4

Please sign in to comment.