- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在测试我的 Angular 应用程序时,我收到了弃用警告
'DEPRECATED: DI is instantiating a token "MockLocationStrategy" that inherits its @Injectable decorator but does not provide one itself.This will become an error in a future version of Angular. Please add @Injectable() to the "MockLocationStrategy" class.'
describe('BookComponent', () => {
let component: BookComponent;
let fixture: ComponentFixture<BookIssueComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [
RouterTestingModule,
],
declarations: [BookComponent]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(BookComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
我相信这个警告是因为我更新了我的包
Package Current Wanted Latest Location
@angular-devkit/architect 0.1102.11 0.1102.13 0.1200.1 node_modules/@angular-devkit/architect
@angular-devkit/build-angular 0.1102.11 0.1102.13 12.0.1 node_modules/@angular-devkit/build-angular
@angular-eslint/builder 4.2.0 4.3.0 12.0.0 node_modules/@angular-eslint/builder
@angular-eslint/eslint-plugin 4.2.0 4.3.0 12.0.0 node_modules/@angular-eslint/eslint-plugin
@angular-eslint/eslint-plugin-template 4.2.0 4.3.0 12.0.0 node_modules/@angular-eslint/eslint-plugin-template
@angular-eslint/schematics 4.2.0 4.3.0 12.0.0 node_modules/@angular-eslint/schematics
@angular-eslint/template-parser 4.2.0 4.3.0 12.0.0 node_modules/@angular-eslint/template-parser
@angular/animations 11.2.12 11.2.14 12.0.1 node_modules/@angular/animations
@angular/cdk 11.2.11 11.2.13 12.0.1 node_modules/@angular/cdk
@angular/cli 11.2.11 11.2.13 12.0.1 node_modules/@angular/cli
@angular/common 11.2.12 11.2.14 12.0.1 node_modules/@angular/common
@angular/compiler 11.2.12 11.2.14 12.0.1 node_modules/@angular/compiler
@angular/compiler-cli 11.2.12 11.2.14 12.0.1 node_modules/@angular/compiler-cli
@angular/core 11.2.12 11.2.14 12.0.1 node_modules/@angular/core
@angular/forms 11.2.12 11.2.14 12.0.1 node_modules/@angular/forms
@angular/language-service 11.2.12 11.2.14 12.0.1 node_modules/@angular/language-service
@angular/platform-browser 11.2.12 11.2.14 12.0.1 node_modules/@angular/platform-browser
@angular/platform-browser-dynamic 11.2.12 11.2.14 12.0.1 node_modules/@angular/platform-browser-dynamic
@angular/pwa 0.1102.11 0.1102.13 12.0.1 node_modules/@angular/pwa
@angular/router 11.2.12 11.2.14 12.0.1 node_modules/@angular/router
@angular/service-worker 11.2.12 11.2.14 12.0.1 node_modules/@angular/service-worker
@ngrx/component 11.1.1 11.1.1 12.0.0 node_modules/@ngrx/component
@ngrx/effects 11.1.1 11.1.1 12.0.0 node_modules/@ngrx/effects
@ngrx/entity 11.1.1 11.1.1 12.0.0 node_modules/@ngrx/entity
@ngrx/schematics 11.1.1 11.1.1 12.0.0 node_modules/@ngrx/schematics
@ngrx/store 11.1.1 11.1.1 12.0.0 node_modules/@ngrx/store
@ngrx/store-devtools 11.1.1 11.1.1 12.0.0 node_modules/@ngrx/store-devtools
@tinymce/tinymce-angular 4.2.2 4.2.3 4.2.3 node_modules/@tinymce/tinymce-angular
@types/jasmine 3.6.10 3.7.4 3.7.4 node_modules/@types/jasmine
@types/jasminewd2 2.0.8 2.0.9 2.0.9 node_modules/@types/jasminewd2
@types/node 15.0.1 15.6.0 15.6.0 node_modules/@types/node
@typescript-eslint/eslint-plugin 4.22.0 4.22.0 4.24.0 node_modules/@typescript-eslint/eslint-plugin
@typescript-eslint/parser 4.22.0 4.22.0 4.24.0 node_modules/@typescript-eslint/parser
bootstrap 4.6.0 4.6.0 5.0.1 node_modules/bootstrap
eslint 7.25.0 7.26.0 7.26.0 node_modules/eslint
eslint-plugin-import 2.22.1 2.22.1 2.23.2 node_modules/eslint-plugin-import
eslint-plugin-jsdoc 33.0.0 33.0.0 34.8.2 node_modules/eslint-plugin-jsdoc
google-libphonenumber 3.2.19 3.2.21 3.2.21 node_modules/google-libphonenumber
ng2-pdf-viewer 6.4.1 6.4.1 7.0.1 node_modules/ng2-pdf-viewer
rxjs 6.6.7 6.6.7 7.1.0 node_modules/rxjs
snyk 1.580.0 1.605.0 1.605.0 node_modules/snyk
tinymce 5.7.1 5.8.1 5.8.1 node_modules/tinymce
typescript 4.1.5 4.1.5 4.2.4 node_modules/typescript
我已尝试关注
docs: RouterTestingModule should be added to Testing guide #34341 的讨论但我不知道如何解决这个问题
最佳答案
使用 withRoutes
提供路线没有为我删除警告。而是提供 MockLocationStrategy
对于 LocationStrategy
对于每个测试导入 RouterTestingModule
为我工作。
import { MockLocationStrategy } from '@angular/common/testing';
import { RouterTestingModule } from '@angular/router/testing';
然后在
TestBed.configureTestingModule
{ provide: LocationStrategy, useClass: MockLocationStrategy },
我在这里找到了答案:
https://github.com/angular/angular/issues/34341#issuecomment-864281500
关于javascript - 已弃用 : DI is instantiating a token "MockLocationStrategy" that inherits its @Injectable decorator but does not provide one itself,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67643040/
我正在为我的项目测试 FlowJS,我遇到了 Type Aliases 的问题. 我为 API 构建了一个 Web SDK:我有一个使用此方法的 Helper 类: class Helper {
我是 Dart 的新手,仍在学习它带来的所有细微差别。我当前的任务真正困扰的一件事是从父类继承(或代理)静态方法。 void main() { EnglishCasual.greet(); } c
我正在尝试巩固 Go 提供的继承概念(也许是“组合”而不是纯粹的继承)。但是,我无法理解为什么我不能将“父”类型用作 func 参数来生成作用于该参数的通用函数。 package main impor
我在准确表述它时遇到问题,所以我在标题中留下了更笼统的描述(如果您对问题有更准确的描述,请发表评论,我会编辑标题)。 问题: AudioStream 和VideoStream 两个类派生自基类Medi
我的应用程序不仅具有“用户”,而且还具有“管理员”和“ super 管理员”。由于所有这三个共享相同的属性,因此我只想使用一个带有附加属性“role”的表,该属性可以是“user”,“admin”或“
我正在使用数据库优先方法和 DbContext。我的数据模型中有几个继承结构 (TPH)。但是 DbContext 只为基类创建一个 DbSet,而没有为子类创建一个 DbSet。我应该如何检索指定子
我正在使用数据库优先方法和 DbContext。我的数据模型中有几个继承结构 (TPH)。但是 DbContext 只为基类创建一个 DbSet,而没有为子类创建一个 DbSet。我应该如何检索指定子
我有一个生成很多子对象的应用程序,每个子对象都与一些全局应用程序对象一起工作,例如在全局应用程序注册表中注册自己,更新应用程序统计信息等。 应用程序应该如何将访问这些全局对象的能力传递给 child
我有 2 个结构,其中一个继承了由 type Common struct {...} 表示的所有结构中共有的值 type Common struct{ Id int CreatedAt
我的代码: Ext.onReady(function() { // Every property is declared inside the class Ext.define('MyCustomPa
我有一个包含多个类的应用程序,这些类继承/是第三方库类的子类。例如,来自 Qt Framework 的 QDialog。 我应该在应用程序的 UML 类图中指定继承关系吗? 是否期望(或标准)表示此类
我遇到了这个问题,因为我认为我对 Backbone 的理解不正确。 我有一个名为 Runnable 的父类(super class)和一组继承自它的子类: var Runnable = Backbon
考虑以下 HTML: foo bar 和 CSS: a { text-decoration:none; border-bottom-width: 0px; border-bot
我想做个模板Class BaseDialog ,但在进行最终对话时 MyDialog1 , 继承了 BaseDialog , 我收到错误,然后无法在设计模式下显示对话框。 以下是我得到的错误列表。 a
我对 android 文档中的这两个术语感到困惑!! these screenshot about what i mean 最佳答案 常量是用 static 和 final 修饰符声明的字段。继承常量
我最近遇到了一个新的警告: 继承构造函数不继承省略号 我正在尝试管道 Object{42}; // ... into an init that handles integers ...和... Obj
我正在使用 TypeScript 开发 Aurelia 应用程序。在此应用程序中,我定义了一组自定义元素,每个元素共享一组可绑定(bind)属性,这些属性被转换为 css 设置,如以下简化示例所示:
我想知道为什么人们会说: “继承类不继承构造函数”。 如果你可以使用父类的构造函数,无参构造函数无论如何都会被自动调用。 例子: #include using namespace std; clas
我刚刚开始探索 Kotlin 语言。我正在为继承、var&val 和副作用而苦苦挣扎。 如果我用 val x 声明一个特征 A 并在 AImpl 中覆盖 x ,则可以将其覆盖为 var(参见下面的代码
我正面临一个编码/解码问题,涉及使用 MOXy 的 JAXB 实现和外部元数据绑定(bind)文件的继承和多态性。 我无法控制 XML 文件或模型类。 模型内部有多个类继承其他 DTO 类。 这是我正
我是一名优秀的程序员,十分优秀!