我在我的角度应用程序中配置了茉莉花测试。
我运行它,现在出现以下错误:
错误:遇到未定义的提供者!通常,这意味着您具有循环依赖关系。这可能是由于使用“桶” index.ts文件引起的。
此错误正在验证服务中出现。但是在此服务中有注意。
import {
HttpClientTestingModule,
HttpTestingController
} from "@angular/common/http/testing";
import { TestBed, getTestBed } from "@angular/core/testing";
import { AuthService } from "./auth.service";
describe("AuthService", () => {
let injector: TestBed;
let authService: AuthService;
let httpMock: HttpTestingController;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
providers: [authService]
});
injector = getTestBed();
authService = injector.get(authService);
httpMock = injector.get(HttpTestingController);
});
afterEach(() => {
httpMock.verify();
});
it("should be created", () => {
const service: AuthService = TestBed.get(AuthService);
expect(service).toBeTruthy();
});
});
auth service.ts就是这样:
import { Router } from '@angular/router';
import { BehaviorSubject } from 'rxjs';
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class AuthService {
private loggedIn = new BehaviorSubject<boolean>(false);
constructor(private router: Router) { }
get isLoggedIn() {
return this.loggedIn.asObservable();
}
login() {
if (true) {
this.loggedIn.next(true);
this.router.navigate(['/']);
}
}
}
这是我的第一个问题,第二个问题是:
_this.$instance.slick is not a function
但是在htmo中,我使用了:
<ngx-slick-carousel class="carousel" #slickModal="slick-carousel" [config]="slideConfig">
<div ngxSlickItem *ngFor="let slide of slides" class="slide" style="text-align: -webkit-center;">
<img src="{{ slide.img }}" alt="" width="60rem" height="60rem">
</div>
</ngx-slick-carousel>
有什么解决方案吗?
最好的问候,