first is not a function while writing Jasmine test cases using angular 2-4
I am facing error while writing test cases with jasmine
I am writing test case for below code
@select([
'reportingTabState',
'actualDelayDetails',
'ActualDelayDetailsResponse',
'DelayDetails',
'actualDelayDetails',
])
actualDelayDetails$;
this.actualDelayDetailsSub = this.actualDelayDetails$
.first()
.subscribe(actualDelayDetails => {
//rest of the code..
});
Mocking it in my spec.ts like this
const actualDelay$ = MockNgRedux.getSelectorStub([
'ActualDelayDetailsResponse',
]);
actualDelay$.next(actualDelayDetails);
actualDelay$.complete();
Object.defineProperty(component, 'actualDelayDetails$', { writable: true });
component.actualDelayDetails$ = actualDelay$;
fixture.detectChanges();
In actualDelayDetails I am having mock object like this:
const actualDelayDetails = {
ActualDelayDetailsResponse: [{
primaryDelay: {
code: 'CR2F',
minutes: '1 min',
details: 'REPLACEMENT OF A FLIGHT OPS CREWMEMBER D',
detailsDesc: 'REPLACEMENT OF A FLIGHT OPS CREWMEMBER D',
},
secondaryDelay: {
code: 'F06',
minutes: '23 min',
details: 'DUE TO CAPTAIN DISCRETION TO NOT ACCEPT',
detailsDesc: 'DUE TO CAPTAIN DISCRETION TO NOT ACCEPT',
},
}],
};
Please help me out with this.
angular redux jasmine jestjs
add a comment |
I am facing error while writing test cases with jasmine
I am writing test case for below code
@select([
'reportingTabState',
'actualDelayDetails',
'ActualDelayDetailsResponse',
'DelayDetails',
'actualDelayDetails',
])
actualDelayDetails$;
this.actualDelayDetailsSub = this.actualDelayDetails$
.first()
.subscribe(actualDelayDetails => {
//rest of the code..
});
Mocking it in my spec.ts like this
const actualDelay$ = MockNgRedux.getSelectorStub([
'ActualDelayDetailsResponse',
]);
actualDelay$.next(actualDelayDetails);
actualDelay$.complete();
Object.defineProperty(component, 'actualDelayDetails$', { writable: true });
component.actualDelayDetails$ = actualDelay$;
fixture.detectChanges();
In actualDelayDetails I am having mock object like this:
const actualDelayDetails = {
ActualDelayDetailsResponse: [{
primaryDelay: {
code: 'CR2F',
minutes: '1 min',
details: 'REPLACEMENT OF A FLIGHT OPS CREWMEMBER D',
detailsDesc: 'REPLACEMENT OF A FLIGHT OPS CREWMEMBER D',
},
secondaryDelay: {
code: 'F06',
minutes: '23 min',
details: 'DUE TO CAPTAIN DISCRETION TO NOT ACCEPT',
detailsDesc: 'DUE TO CAPTAIN DISCRETION TO NOT ACCEPT',
},
}],
};
Please help me out with this.
angular redux jasmine jestjs
add a comment |
I am facing error while writing test cases with jasmine
I am writing test case for below code
@select([
'reportingTabState',
'actualDelayDetails',
'ActualDelayDetailsResponse',
'DelayDetails',
'actualDelayDetails',
])
actualDelayDetails$;
this.actualDelayDetailsSub = this.actualDelayDetails$
.first()
.subscribe(actualDelayDetails => {
//rest of the code..
});
Mocking it in my spec.ts like this
const actualDelay$ = MockNgRedux.getSelectorStub([
'ActualDelayDetailsResponse',
]);
actualDelay$.next(actualDelayDetails);
actualDelay$.complete();
Object.defineProperty(component, 'actualDelayDetails$', { writable: true });
component.actualDelayDetails$ = actualDelay$;
fixture.detectChanges();
In actualDelayDetails I am having mock object like this:
const actualDelayDetails = {
ActualDelayDetailsResponse: [{
primaryDelay: {
code: 'CR2F',
minutes: '1 min',
details: 'REPLACEMENT OF A FLIGHT OPS CREWMEMBER D',
detailsDesc: 'REPLACEMENT OF A FLIGHT OPS CREWMEMBER D',
},
secondaryDelay: {
code: 'F06',
minutes: '23 min',
details: 'DUE TO CAPTAIN DISCRETION TO NOT ACCEPT',
detailsDesc: 'DUE TO CAPTAIN DISCRETION TO NOT ACCEPT',
},
}],
};
Please help me out with this.
angular redux jasmine jestjs
I am facing error while writing test cases with jasmine
I am writing test case for below code
@select([
'reportingTabState',
'actualDelayDetails',
'ActualDelayDetailsResponse',
'DelayDetails',
'actualDelayDetails',
])
actualDelayDetails$;
this.actualDelayDetailsSub = this.actualDelayDetails$
.first()
.subscribe(actualDelayDetails => {
//rest of the code..
});
Mocking it in my spec.ts like this
const actualDelay$ = MockNgRedux.getSelectorStub([
'ActualDelayDetailsResponse',
]);
actualDelay$.next(actualDelayDetails);
actualDelay$.complete();
Object.defineProperty(component, 'actualDelayDetails$', { writable: true });
component.actualDelayDetails$ = actualDelay$;
fixture.detectChanges();
In actualDelayDetails I am having mock object like this:
const actualDelayDetails = {
ActualDelayDetailsResponse: [{
primaryDelay: {
code: 'CR2F',
minutes: '1 min',
details: 'REPLACEMENT OF A FLIGHT OPS CREWMEMBER D',
detailsDesc: 'REPLACEMENT OF A FLIGHT OPS CREWMEMBER D',
},
secondaryDelay: {
code: 'F06',
minutes: '23 min',
details: 'DUE TO CAPTAIN DISCRETION TO NOT ACCEPT',
detailsDesc: 'DUE TO CAPTAIN DISCRETION TO NOT ACCEPT',
},
}],
};
Please help me out with this.
angular redux jasmine jestjs
angular redux jasmine jestjs
edited Nov 13 '18 at 15:46
skyboyer
3,44111128
3,44111128
asked Nov 13 '18 at 12:53
MonicaMonica
33111
33111
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You probably have a import 'rxjs/add/operator/first'
(or something similar) inside your main.ts
. This will patch the observable used inside your application to include this operator for chaining. You can solve this by including it on top of your test script, or in a global script which is loaded by your test environment.
Even better would be to move to the new way of chaining operators by using pipe()
:
import { first } from 'rxjs/operators';
this.actualDelayDetails$.pipe(
first()
).subscribe(() => {
This way you can be sure that what's used in your file, is also available in your tests
read more here
add a comment |
"The first() operator takes an optional predicate function and emits an error notification when no value matched when the source completed."
So I tried removing first() method and it worked fine without breaking my functionality.
Thanks PierreDuc for instant reply. but unfortunately this solution was not working for me.
add a comment |
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%2f53281455%2ffirst-is-not-a-function-while-writing-jasmine-test-cases-using-angular-2-4%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You probably have a import 'rxjs/add/operator/first'
(or something similar) inside your main.ts
. This will patch the observable used inside your application to include this operator for chaining. You can solve this by including it on top of your test script, or in a global script which is loaded by your test environment.
Even better would be to move to the new way of chaining operators by using pipe()
:
import { first } from 'rxjs/operators';
this.actualDelayDetails$.pipe(
first()
).subscribe(() => {
This way you can be sure that what's used in your file, is also available in your tests
read more here
add a comment |
You probably have a import 'rxjs/add/operator/first'
(or something similar) inside your main.ts
. This will patch the observable used inside your application to include this operator for chaining. You can solve this by including it on top of your test script, or in a global script which is loaded by your test environment.
Even better would be to move to the new way of chaining operators by using pipe()
:
import { first } from 'rxjs/operators';
this.actualDelayDetails$.pipe(
first()
).subscribe(() => {
This way you can be sure that what's used in your file, is also available in your tests
read more here
add a comment |
You probably have a import 'rxjs/add/operator/first'
(or something similar) inside your main.ts
. This will patch the observable used inside your application to include this operator for chaining. You can solve this by including it on top of your test script, or in a global script which is loaded by your test environment.
Even better would be to move to the new way of chaining operators by using pipe()
:
import { first } from 'rxjs/operators';
this.actualDelayDetails$.pipe(
first()
).subscribe(() => {
This way you can be sure that what's used in your file, is also available in your tests
read more here
You probably have a import 'rxjs/add/operator/first'
(or something similar) inside your main.ts
. This will patch the observable used inside your application to include this operator for chaining. You can solve this by including it on top of your test script, or in a global script which is loaded by your test environment.
Even better would be to move to the new way of chaining operators by using pipe()
:
import { first } from 'rxjs/operators';
this.actualDelayDetails$.pipe(
first()
).subscribe(() => {
This way you can be sure that what's used in your file, is also available in your tests
read more here
answered Nov 13 '18 at 13:07
PierreDucPierreDuc
29.2k45376
29.2k45376
add a comment |
add a comment |
"The first() operator takes an optional predicate function and emits an error notification when no value matched when the source completed."
So I tried removing first() method and it worked fine without breaking my functionality.
Thanks PierreDuc for instant reply. but unfortunately this solution was not working for me.
add a comment |
"The first() operator takes an optional predicate function and emits an error notification when no value matched when the source completed."
So I tried removing first() method and it worked fine without breaking my functionality.
Thanks PierreDuc for instant reply. but unfortunately this solution was not working for me.
add a comment |
"The first() operator takes an optional predicate function and emits an error notification when no value matched when the source completed."
So I tried removing first() method and it worked fine without breaking my functionality.
Thanks PierreDuc for instant reply. but unfortunately this solution was not working for me.
"The first() operator takes an optional predicate function and emits an error notification when no value matched when the source completed."
So I tried removing first() method and it worked fine without breaking my functionality.
Thanks PierreDuc for instant reply. but unfortunately this solution was not working for me.
answered Nov 22 '18 at 12:16
MonicaMonica
33111
33111
add a comment |
add a comment |
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%2f53281455%2ffirst-is-not-a-function-while-writing-jasmine-test-cases-using-angular-2-4%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