I am trying to unit test a react project based on the unit testing frameworks used in this
The unit testing for my project is setup exactly like this one. My problem is it does not seem to support less js files. Every time I try to run a test a file that has less in it I receive this error from phantom js
PhantomJS 1.9.8 (Mac OS X 0.0.0) ERROR Error: Cannot find module "./Dashboard.less" at /Unit_Tests/main.js:26577
My main.js file look
/**
* Test suite entry point
*/
// Babel Polyfill
import 'babel-core/polyfill';
import './routes/Home_Test';
//import './routes/Dashboard.less';
and my karma.config.js
/**
* This is the Karma configuration file. It contains information about this skeleton
* that provides the test runner with instructions on how to run the tests and
* generate the code coverage report.
*
* For more info, see: http://ift.tt/1p2y9sn
*/
module.exports = function(config) {
config.set({
/**
* These are the files required to run the tests.
*
* The `Function.prototype.bind` polyfill is required by PhantomJS
* because it uses an older version of JavaScript.
*/
files: [
'./Unit_Tests/polyfill.js',
'./Unit_Tests/main.js'
],
/**
* The actual tests are preprocessed by the karma-webpack plugin, so that
* their source can be properly transpiled.
*/
preprocessors: {
'./Unit_Tests/main.js': ['webpack']
},
/**
* We want to run the tests using the PhantomJS headless browser.
* This is especially useful for continuous integration.
*/
browsers: ['PhantomJS'],
/**
* Use Mocha as the test framework, Sinon for mocking, and
* Chai for assertions.
*/
frameworks: ['mocha', 'sinon-chai'],
/**
* After running the tests, return the results and generate a
* code coverage report.
*/
reporters: ['progress', 'coverage'],
/**
* When generating a code coverage report, use `lcov` format and
* place the result in coverage/lcov.info
*
* This file will be sent to Coveralls by the `coveralls` npm script.
*/
coverageReporter: {
dir: 'coverage/',
reporters: [
{ type: 'lcovonly', subdir: '.', file: 'lcov.info' },
{ type: 'html', subdir: 'html' }
]
},
/**
* The configuration for the karma-webpack plugin.
*
* This is very similar to the main webpack.local.config.js, with the
* exception of specifying an istanbul-transformer post loader so
* that we can generate an accurate code coverage report.
*/
webpack: {
module: {
loaders: [
{ test: /\.jsx?$/, exclude: /node_modules/, loader: "babel-loader?stage=0"}
],
postLoaders: [{
test: /\.jsx?$/,
exclude: /(test|node_modules)\//,
loader: 'istanbul-instrumenter'
}]
},
resolve: {
extensions: ['', '.js', '.jsx']
}
},
/**
* Configuration option to turn off verbose logging of webpack compilation.
*/
webpackMiddleware: {
noInfo: true
},
/**
* Once the mocha test suite returns, we want to exit from the test runner as well.
*/
singleRun: true,
/**
* List of plugins
*/
plugins: [
'karma-mocha',
'karma-webpack',
'karma-coverage',
'karma-sinon-chai',
'karma-phantomjs-launcher'
],
});
}
I have been looking around for a good answer on how to unit test files that contain less but cannot find one. I do not really care about unit testing the css just the jsx files.
Aucun commentaire:
Enregistrer un commentaire