Reputation: 45
Can Jasmine-Karma be implemented for Unit Testing in Angular 2 application without using Webpack? Instead of Webpack, SystemJS is a solution but is it correct to use SystemJS and Webpack in an application simultaneously? I'm using Webpack for development mode and production mode of the application.
Upvotes: 0
Views: 896
Reputation: 28592
Karma and Jasmine has nothing to do with Angular2, they're separate libraries that could run completely separately.
For Karma to run, you'd need :
npm install -g karma-cli
karma init my.conf.js // this will create a configuration file for Karma
karma start my.conf.js
This will look for all your test files and run them and then shows the result in the command line.
But, the problem is when you're dealing with Angular2 code which you normally write in Typescript and the code itself might have some extra dependencies, the Karma configuration might become painful. You might have sass files that needs to be converted into css files first for Karma ( you can think of Karma as the browsers, it needs only JS and CSS and HTML, nothing more).
And like I said, you'd need your typescript code to first be transpiled to Javascript to give it to karma right?
So you need someone to handle this small tasks for you, which is normally webpack in this days, and used to be gulp and grunt.
Webpack is a sophisticated bundler and it does almost everything you might ever need when working with Angular.
I wouldn't recommend using SystemJS and Webpack together because Webpack already does what SystemJS does ( loading files and ... ).
Upvotes: 1