0

I use jsfeat javascript library in my Angular2 project.

I put this at the beginning of my .ts and .spec.ts files:

declare var jsfeat: any;

I included jsfeat.js in my index.html.

Now I want to run Angular2 tests, but I get:

ReferenceError: jsfeat is not defined

The test code is:

describe('MyObj instance', function () {
  it('should instantiate MyObj', () => {
    expect(new MyObj()).toBeDefined('Whoopie!');
  });
});
Admdebian
  • 630
  • 6
  • 17

1 Answers1

0

1) INSTALL JSFEAT WITH NPM (optional):

npm install -g jsfeat

2) EDIT karma.conf.js:

  config.set({

[...]

files: [
  // System.js for module loading
  'node_modules/systemjs/dist/system.src.js',

  // Polyfills
  'node_modules/core-js/client/shim.js',

  // Reflect and Zone.js
  'node_modules/reflect-metadata/Reflect.js',
  'node_modules/zone.js/dist/zone.js',
  'node_modules/zone.js/dist/jasmine-patch.js',
  'node_modules/zone.js/dist/async-test.js',
  'node_modules/zone.js/dist/fake-async-test.js',

[...]

Add jsfeat:

  'node_modules/jsfeat/build/jsfeat.js',
Admdebian
  • 630
  • 6
  • 17