警告:'The "slidestart" event cannot be bound because Hammer.JS is not loaded and no custom loader has been specified.'
WARN: 'The "slidestart" event cannot be bound because Hammer.JS is not loaded and no custom loader has been specified.'
当 运行 单元测试
时,TFS 构建输出中出现此错误
我通过简单地在 test.ts
中添加一个导入解决了这个问题
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
import 'zone.js/dist/zone-testing';
**import 'hammerjs';**
declare const require: any;
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting()
);
// Then we find all the tests.
const context = require.context( './', true, /\.spec\.ts$/ );
// And load the modules.
context.keys().map( context );
添加以下提供商为我解决了这个问题:
...
import { HAMMER_LOADER } from '@angular/platform-browser';
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ... ],
imports: [ ... ],
providers: [
...,
{ provide: HAMMER_LOADER, useValue: () => new Promise(() => {}) } ]
})
.compileComponents();
}));
当 运行 单元测试
时,TFS 构建输出中出现此错误我通过简单地在 test.ts
中添加一个导入解决了这个问题
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
import 'zone.js/dist/zone-testing';
**import 'hammerjs';**
declare const require: any;
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting()
);
// Then we find all the tests.
const context = require.context( './', true, /\.spec\.ts$/ );
// And load the modules.
context.keys().map( context );
添加以下提供商为我解决了这个问题:
...
import { HAMMER_LOADER } from '@angular/platform-browser';
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ... ],
imports: [ ... ],
providers: [
...,
{ provide: HAMMER_LOADER, useValue: () => new Promise(() => {}) } ]
})
.compileComponents();
}));