-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Including dependencies in karma.config.js
Valentyn Yakymenko edited this page Nov 29, 2016
·
2 revisions
After adding any dependencies to your seed project, you can have problems with test runners. Errors example:
The project builds in both dev and prod, however when I run test I get:
23 11 2016 08:57:45.846:WARN [web-server]: 404: /base/node_modules/ng2-dragula/ng2-dragula.js
Chrome 54.0.2840 (Windows 10 0.0.0) ERROR: '(SystemJS) XHR error (404 Not Found) loading http://localhost:9876/base/node_modules/ng2-d
ragula/ng2-dragula.js
Error: XHR error (404 Not Found) loading http://localhost:9876/base/node_modules/ng2-dragula/ng2-dragula.js
at XMLHttpRequest.wrapFn [as _onreadystatechange] (http://localhost:9876/base/node_modules/zone.js/dist/zone.js?c35727d0e6
4913b5669320b167e496fc94fc6928:647:29)
at ZoneDelegate.invokeTask (http://localhost:9876/base/node_modules/zone.js/dist/zone.js?
It's a normal case because we need to configure our karma.config.js
file and add there our new dependency
.
I will provide example based on ng2-dragula
with dragula
npm package:
$ git clone --depth 1 https://github.com/mgechev/angular2-seed.git
$ cd angular2-seed
$ npm install
$ npm i dragula ng2-dragula --save
src/client/app/shared/shared.module.ts
...
import { DragulaModule } from 'ng2-dragula/ng2-dragula';
...
@NgModule({
...
exports: [ToolbarComponent, NavbarComponent,
CommonModule, FormsModule, RouterModule, DragulaModule]
....
karma.config.js
...
module.exports = function (config) {
config.set({
....
// Dragula
{ pattern: 'node_modules/dragula/**/*.js', included: false, watched: true },
{ pattern: 'node_modules/ng2-dragula/**/*.js', included: false, watched: true },
...
$ npm test