Angular7 Integration tests of component “Failed: Uncaught (in promise): TypeError:”
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I keep getting this error and have been through the docs and various threads and can't figure out why these errors are happening as they don't make any sense.
My spec configuration with 1 single simple test:
describe('AddVideoComponent', () =>
let component: AddVideoComponent;
let fixture: ComponentFixture<AddVideoComponent>;
beforeEach(async(() =>
TestBed.configureTestingModule(
imports: [
ReactiveFormsModule,
HttpClientModule,
MatSnackBarModule,
FormsModule
],
declarations: [AddVideoComponent, CleanLinkPipe],
providers: [RestService, NgRedux, AdalService],
schemas: [NO_ERRORS_SCHEMA]
)
.compileComponents()
.then(() =>
fixture = TestBed.createComponent(AddVideoComponent);
component = fixture.componentInstance;
fixture.detectChanges();
);
));
it('should create form group with 5 controls', () =>
component.ngOnInit();
fixture.detectChanges();
expect(component.addVideoForm.contains('title')).toBeTruthy();
);
);
Errors I'm getting:
Failed: Uncaught (in promise): TypeError: Cannot read property 'subscribe' of undefined
+
TypeError: Cannot read property 'ngOnInit' of undefined
Now in my component, I'm not subscribing to anything in any way, there's no subscriptions of any kind.
angular integration-testing angular7 angular-test
add a comment |
I keep getting this error and have been through the docs and various threads and can't figure out why these errors are happening as they don't make any sense.
My spec configuration with 1 single simple test:
describe('AddVideoComponent', () =>
let component: AddVideoComponent;
let fixture: ComponentFixture<AddVideoComponent>;
beforeEach(async(() =>
TestBed.configureTestingModule(
imports: [
ReactiveFormsModule,
HttpClientModule,
MatSnackBarModule,
FormsModule
],
declarations: [AddVideoComponent, CleanLinkPipe],
providers: [RestService, NgRedux, AdalService],
schemas: [NO_ERRORS_SCHEMA]
)
.compileComponents()
.then(() =>
fixture = TestBed.createComponent(AddVideoComponent);
component = fixture.componentInstance;
fixture.detectChanges();
);
));
it('should create form group with 5 controls', () =>
component.ngOnInit();
fixture.detectChanges();
expect(component.addVideoForm.contains('title')).toBeTruthy();
);
);
Errors I'm getting:
Failed: Uncaught (in promise): TypeError: Cannot read property 'subscribe' of undefined
+
TypeError: Cannot read property 'ngOnInit' of undefined
Now in my component, I'm not subscribing to anything in any way, there's no subscriptions of any kind.
angular integration-testing angular7 angular-test
Provide your component code at least, and at best a Minimal, Complete, and Verifiable example of the issue.
– trichetriche
Nov 16 '18 at 12:47
My best guess without any further code is that there is an error occurring while trying to create your component (the first error), thus the component is never being initialized and causing the second error. Can you provide the code for yourAddVideoComponent
?
– Daniel W Strimpel
Nov 16 '18 at 20:30
@DanielWStrimpel -- ah, you are right. I found out that my integration test was a bit too much and instead should've just use a test-class for the rest service, not the whole rest service itself. Seems like such an obvious mistake now, sorry! Happy to mark your answer as right if you post it as an answer.
– SebastianG
Nov 17 '18 at 20:10
add a comment |
I keep getting this error and have been through the docs and various threads and can't figure out why these errors are happening as they don't make any sense.
My spec configuration with 1 single simple test:
describe('AddVideoComponent', () =>
let component: AddVideoComponent;
let fixture: ComponentFixture<AddVideoComponent>;
beforeEach(async(() =>
TestBed.configureTestingModule(
imports: [
ReactiveFormsModule,
HttpClientModule,
MatSnackBarModule,
FormsModule
],
declarations: [AddVideoComponent, CleanLinkPipe],
providers: [RestService, NgRedux, AdalService],
schemas: [NO_ERRORS_SCHEMA]
)
.compileComponents()
.then(() =>
fixture = TestBed.createComponent(AddVideoComponent);
component = fixture.componentInstance;
fixture.detectChanges();
);
));
it('should create form group with 5 controls', () =>
component.ngOnInit();
fixture.detectChanges();
expect(component.addVideoForm.contains('title')).toBeTruthy();
);
);
Errors I'm getting:
Failed: Uncaught (in promise): TypeError: Cannot read property 'subscribe' of undefined
+
TypeError: Cannot read property 'ngOnInit' of undefined
Now in my component, I'm not subscribing to anything in any way, there's no subscriptions of any kind.
angular integration-testing angular7 angular-test
I keep getting this error and have been through the docs and various threads and can't figure out why these errors are happening as they don't make any sense.
My spec configuration with 1 single simple test:
describe('AddVideoComponent', () =>
let component: AddVideoComponent;
let fixture: ComponentFixture<AddVideoComponent>;
beforeEach(async(() =>
TestBed.configureTestingModule(
imports: [
ReactiveFormsModule,
HttpClientModule,
MatSnackBarModule,
FormsModule
],
declarations: [AddVideoComponent, CleanLinkPipe],
providers: [RestService, NgRedux, AdalService],
schemas: [NO_ERRORS_SCHEMA]
)
.compileComponents()
.then(() =>
fixture = TestBed.createComponent(AddVideoComponent);
component = fixture.componentInstance;
fixture.detectChanges();
);
));
it('should create form group with 5 controls', () =>
component.ngOnInit();
fixture.detectChanges();
expect(component.addVideoForm.contains('title')).toBeTruthy();
);
);
Errors I'm getting:
Failed: Uncaught (in promise): TypeError: Cannot read property 'subscribe' of undefined
+
TypeError: Cannot read property 'ngOnInit' of undefined
Now in my component, I'm not subscribing to anything in any way, there's no subscriptions of any kind.
angular integration-testing angular7 angular-test
angular integration-testing angular7 angular-test
edited Nov 16 '18 at 20:27
Daniel W Strimpel
3,7811719
3,7811719
asked Nov 16 '18 at 12:25
SebastianGSebastianG
1,081320
1,081320
Provide your component code at least, and at best a Minimal, Complete, and Verifiable example of the issue.
– trichetriche
Nov 16 '18 at 12:47
My best guess without any further code is that there is an error occurring while trying to create your component (the first error), thus the component is never being initialized and causing the second error. Can you provide the code for yourAddVideoComponent
?
– Daniel W Strimpel
Nov 16 '18 at 20:30
@DanielWStrimpel -- ah, you are right. I found out that my integration test was a bit too much and instead should've just use a test-class for the rest service, not the whole rest service itself. Seems like such an obvious mistake now, sorry! Happy to mark your answer as right if you post it as an answer.
– SebastianG
Nov 17 '18 at 20:10
add a comment |
Provide your component code at least, and at best a Minimal, Complete, and Verifiable example of the issue.
– trichetriche
Nov 16 '18 at 12:47
My best guess without any further code is that there is an error occurring while trying to create your component (the first error), thus the component is never being initialized and causing the second error. Can you provide the code for yourAddVideoComponent
?
– Daniel W Strimpel
Nov 16 '18 at 20:30
@DanielWStrimpel -- ah, you are right. I found out that my integration test was a bit too much and instead should've just use a test-class for the rest service, not the whole rest service itself. Seems like such an obvious mistake now, sorry! Happy to mark your answer as right if you post it as an answer.
– SebastianG
Nov 17 '18 at 20:10
Provide your component code at least, and at best a Minimal, Complete, and Verifiable example of the issue.
– trichetriche
Nov 16 '18 at 12:47
Provide your component code at least, and at best a Minimal, Complete, and Verifiable example of the issue.
– trichetriche
Nov 16 '18 at 12:47
My best guess without any further code is that there is an error occurring while trying to create your component (the first error), thus the component is never being initialized and causing the second error. Can you provide the code for your
AddVideoComponent
?– Daniel W Strimpel
Nov 16 '18 at 20:30
My best guess without any further code is that there is an error occurring while trying to create your component (the first error), thus the component is never being initialized and causing the second error. Can you provide the code for your
AddVideoComponent
?– Daniel W Strimpel
Nov 16 '18 at 20:30
@DanielWStrimpel -- ah, you are right. I found out that my integration test was a bit too much and instead should've just use a test-class for the rest service, not the whole rest service itself. Seems like such an obvious mistake now, sorry! Happy to mark your answer as right if you post it as an answer.
– SebastianG
Nov 17 '18 at 20:10
@DanielWStrimpel -- ah, you are right. I found out that my integration test was a bit too much and instead should've just use a test-class for the rest service, not the whole rest service itself. Seems like such an obvious mistake now, sorry! Happy to mark your answer as right if you post it as an answer.
– SebastianG
Nov 17 '18 at 20:10
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53337890%2fangular7-integration-tests-of-component-failed-uncaught-in-promise-typeerro%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53337890%2fangular7-integration-tests-of-component-failed-uncaught-in-promise-typeerro%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Provide your component code at least, and at best a Minimal, Complete, and Verifiable example of the issue.
– trichetriche
Nov 16 '18 at 12:47
My best guess without any further code is that there is an error occurring while trying to create your component (the first error), thus the component is never being initialized and causing the second error. Can you provide the code for your
AddVideoComponent
?– Daniel W Strimpel
Nov 16 '18 at 20:30
@DanielWStrimpel -- ah, you are right. I found out that my integration test was a bit too much and instead should've just use a test-class for the rest service, not the whole rest service itself. Seems like such an obvious mistake now, sorry! Happy to mark your answer as right if you post it as an answer.
– SebastianG
Nov 17 '18 at 20:10