Skip to content
This repository has been archived by the owner on Jul 6, 2021. It is now read-only.

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Reverted istanbul-instrumter-loader ref
webpack-contrib/istanbul-instrumenter-loader#32
  • Loading branch information
patroza authored and paibamboo committed Jan 23, 2017
1 parent 880f623 commit fdc9c03
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 47 deletions.
68 changes: 36 additions & 32 deletions config/test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,29 @@ module.exports = function (config) {
devtool: 'inline-source-map',

resolve: {
root: path.resolve(__dirname),
modulesDirectories: [
modules: [
path.resolve(__dirname),
'../../src',
'../../src/app',
'../../src/app/redux',
'node_modules'
],
extensions: ['', '.json', '.js', '.ts', '.tsx', '.jsx']
extensions: ['.json', '.js', '.ts', '.tsx', '.jsx']
},

module: {
preLoaders: [{
test: /\.tsx?$/,
loader: 'tslint'
}],
loaders: [{
rules: [{
enforce: 'pre',
test: /\.tsx?$/,
loader: 'ts'
loader: 'tslint-loader'
},
{
test: /\.tsx?$/,
loader: 'awesome-typescript-loader?useCache=false'
},
{
test: /\.(jpe?g|png|gif)$/i,
loader: 'url?limit=1000&name=images/[hash].[ext]'
loader: 'url-loader?limit=1000&name=images/[hash].[ext]'
},
{
test: /\.json$/,
Expand All @@ -76,35 +77,23 @@ module.exports = function (config) {
test: /\.css$/,
include: path.resolve('./src/app'),
loaders: [
'style',
'css?modules&importLoaders=2&localIdentName=[local]___[hash:base64:5]',
'postcss'
'style-loader',
'css-loader?modules&importLoaders=2&localIdentName=[local]___[hash:base64:5]',
'postcss-loader'
]
},
{
test: /\.css$/,
exclude: path.resolve('./src/app'),
loader: 'style!css'
loader: 'style-loader!css-loader'
},
{
enforce: 'post',
test: /\.tsx?$/,
loader: 'istanbul-instrumenter-loader',
include: path.resolve('./src/app')
}
],
postLoaders: [{
test: /\.tsx?$/,
loader: 'istanbul-instrumenter-loader',
include: path.resolve('./src/app')
}]
},

postcss: function () {
return [
postcssNext(),
postcssAssets({
relative: true
}),
];
},

tslint: {
failOnHint: true
},

externals: {
Expand All @@ -113,6 +102,21 @@ module.exports = function (config) {
},

plugins: [
new webpack.LoaderOptionsPlugin({
options: {
tslint: {
failOnHint: true
},
postcss: function () {
return [
postcssNext(),
postcssAssets({
relative: true
}),
];
},
}
}),
new webpack.IgnorePlugin(/^fs$/),
new webpack.IgnorePlugin(/^react\/addons$/),
new webpack.NoEmitOnErrorsPlugin(),
Expand Down
5 changes: 1 addition & 4 deletions config/webpack/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ var postcssAssets = require('postcss-assets');
var postcssNext = require('postcss-cssnext');
var stylelint = require('stylelint');
var ManifestPlugin = require('webpack-manifest-plugin');

const {
CheckerPlugin
} = require('awesome-typescript-loader')
var CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin;

var config = {
// Enable sourcemaps for debugging webpack's output.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"fetch-mock": "^5.8.1",
"file-loader": "^0.9.0",
"isomorphic-style-loader": "^1.1.0",
"istanbul-instrumenter-loader": "^1.2.0",
"istanbul-instrumenter-loader": "^0.2.0",
"json-loader": "^0.5.4",
"karma": "^1.4.0",
"karma-chai": "^0.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/app/helpers/TestHelper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function renderComponent(ComponentClass, state?, props?) {
return mount(
<Provider store={store}>
<ComponentClass {...props} />
</Provider>
</Provider>,
);
}

Expand Down
6 changes: 3 additions & 3 deletions src/app/redux/modules/counter/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { expect } from 'chai';
import * as counter from './';
import { ICounter, ICounterAction } from 'models/counter';
import { ICounter, ICounterAction } from 'models/counter';

/** Module */
describe('Counter Module', () => {
Expand All @@ -25,7 +25,7 @@ describe('Counter Module', () => {
/** Reducer */
describe('Reducer', () => {

let state: ICounter = { count: 10 };
const state: ICounter = { count: 10 };

it('handles action of type INCREMENT', () => {
const action: ICounterAction = { type: counter.INCREMENT };
Expand Down
12 changes: 6 additions & 6 deletions src/app/redux/modules/stars/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import { expect } from 'chai';
import { fetchMock, mockStore } from 'helpers/TestHelper.tsx';
import * as stars from './';
import { IStarsAction } from 'models/stars';
import { IStarsAction } from 'models/stars';

/** Mock Data */
const githubResponse = {
Expand Down Expand Up @@ -34,15 +34,15 @@ describe('Stars Module', () => {

const expectedActions: IStarsAction[] = [
{ type: stars.GET_REQUEST },
{ type: stars.GET_SUCCESS, payload: { count: githubResponse.stargazers_count } },
{ type: stars.GET_SUCCESS, payload: { count: githubResponse.stargazers_count } },
];

const store = mockStore({});

store.dispatch(stars.getStars())
.then(() => expect(store.getActions()).to.eql(expectedActions))
.then(() => done())
.catch(err => done(err));
.catch((err) => done(err));
});

/** 400 */
Expand All @@ -55,15 +55,15 @@ describe('Stars Module', () => {

const expectedActions: IStarsAction[] = [
{ type: stars.GET_REQUEST },
{ type: stars.GET_FAILURE, payload: { message: errResponse } },
{ type: stars.GET_FAILURE, payload: { message: errResponse } },
];

const store = mockStore({});

store.dispatch(stars.getStars())
.then(() => expect(store.getActions()).to.eql(expectedActions))
.then(() => done())
.catch(err => done(err));
.catch((err) => done(err));
});

});
Expand Down

0 comments on commit fdc9c03

Please sign in to comment.