Help setting up testbed for service testing #2386
Unanswered
AukeSteenman
asked this question in
Q&A
Replies: 1 comment
-
|
Hey there! You need to mock away or at least redeclare all dependencies from the constructor: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, i'm trying to write some unit tests for fun. I see a lot of spec files where people tried to test services for example the project service. I am trying atm to test the TaskService but I am unable to get the testbed sorted for testing. I get a lot of errors that providers are missing and later errors about security issues for example security Error: Failed to construct 'Worker': Script at ...
Any recommendations of how to proceed? Thanks! (i'm a newbie so go easy on me :p)
This is what I have as a testbed atm
TestBed.configureTestingModule({
imports: [TasksModule],
providers: [
{ provide: TaskService, useClass: TaskService },
],
});
and I inject the service like this
const service: TaskService = TestBed.inject(TaskService);
Beta Was this translation helpful? Give feedback.
All reactions