我在Angular2项目中使用jsfeat javascript库。
我把它放在.ts和.spec.ts文件的开头:
ReferenceError: jsfeat is not defined
我在index.html中包含了jsfeat.js.
现在我想运行Angular2测试,但是我得到了:
describe('MyObj instance', function () {
it('should instantiate MyObj', () => {
expect(new MyObj()).toBeDefined('Whoopie!');
});
});
测试代码是:
{{1}}
答案 0 :(得分:0)
1)使用NPM安装JSFEAT(可选):
npm install -g jsfeat
2)编辑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',
[...]
添加jsfeat:
'node_modules/jsfeat/build/jsfeat.js',