TypeError: routingState.equals is not a function | Jest test case
This is my selector.js file:-
const makeSelectLocationState = () => {
let prevRoutingState;
let prevRoutingStateJS;
return (state) => {
const routingState = state.get('route'); // or state.route
if (!routingState.equals(prevRoutingState)) {
prevRoutingState = routingState;
prevRoutingStateJS = routingState.toJS();
}
return prevRoutingStateJS;
};
};
and the following test case I have written:-
it('makeSelectLocationState function testing', () => {
const selectLocationState = makeSelectLocationState();
const mockedState = fromJS({
route: '',
});
expect(selectLocationState(mockedState)).toEqual('');
});
While running the test case using jest I get the following error:-
TypeError: routingState.equals is not a function
javascript reactjs react-redux jestjs enzyme
add a comment |
This is my selector.js file:-
const makeSelectLocationState = () => {
let prevRoutingState;
let prevRoutingStateJS;
return (state) => {
const routingState = state.get('route'); // or state.route
if (!routingState.equals(prevRoutingState)) {
prevRoutingState = routingState;
prevRoutingStateJS = routingState.toJS();
}
return prevRoutingStateJS;
};
};
and the following test case I have written:-
it('makeSelectLocationState function testing', () => {
const selectLocationState = makeSelectLocationState();
const mockedState = fromJS({
route: '',
});
expect(selectLocationState(mockedState)).toEqual('');
});
While running the test case using jest I get the following error:-
TypeError: routingState.equals is not a function
javascript reactjs react-redux jestjs enzyme
add a comment |
This is my selector.js file:-
const makeSelectLocationState = () => {
let prevRoutingState;
let prevRoutingStateJS;
return (state) => {
const routingState = state.get('route'); // or state.route
if (!routingState.equals(prevRoutingState)) {
prevRoutingState = routingState;
prevRoutingStateJS = routingState.toJS();
}
return prevRoutingStateJS;
};
};
and the following test case I have written:-
it('makeSelectLocationState function testing', () => {
const selectLocationState = makeSelectLocationState();
const mockedState = fromJS({
route: '',
});
expect(selectLocationState(mockedState)).toEqual('');
});
While running the test case using jest I get the following error:-
TypeError: routingState.equals is not a function
javascript reactjs react-redux jestjs enzyme
This is my selector.js file:-
const makeSelectLocationState = () => {
let prevRoutingState;
let prevRoutingStateJS;
return (state) => {
const routingState = state.get('route'); // or state.route
if (!routingState.equals(prevRoutingState)) {
prevRoutingState = routingState;
prevRoutingStateJS = routingState.toJS();
}
return prevRoutingStateJS;
};
};
and the following test case I have written:-
it('makeSelectLocationState function testing', () => {
const selectLocationState = makeSelectLocationState();
const mockedState = fromJS({
route: '',
});
expect(selectLocationState(mockedState)).toEqual('');
});
While running the test case using jest I get the following error:-
TypeError: routingState.equals is not a function
javascript reactjs react-redux jestjs enzyme
javascript reactjs react-redux jestjs enzyme
asked Nov 13 '18 at 6:03
ShwetankShwetank
14129
14129
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
The problem is here:
const routingState = state.get('route');
Sense you didn't get the routingState,possible undefined, so you will get this above error message.So check the date of routingState.
And in the test file, pass mockedState to selectLocationState
selectLocationState(mockedState)
However,makeSelectLocationState function didn't have property.Maybe change to this:
const makeSelectLocationState = (state) => {}
TypeError: Cannot read property 'equals' of undefined. After making the changes I get this above error. @root
– Shwetank
Nov 13 '18 at 7:05
@Shwetank please provide the output of console.log(routingState) in makeSelectLocationState.
– Root
Nov 13 '18 at 7:07
The output of the console.log(routingState) is Map {size: 1, _root: ArrayMapNode, __ownerID: undefined, __hash: undefined, __altered: false} @root
– Shwetank
Nov 13 '18 at 7:22
@Shwetank while the type of routingState is Map,and Map actually don't have equals function.You can use this:routingState.toString() === prevRoutingState.toString() or use forEach to check every item of routingState.
– Root
Nov 13 '18 at 7:56
add a comment |
route: ''
const routingState = state.get('route');
It looks like route is a string (an empty string). Strings do not have an equals method, so routingState.equals() doesn't exist.
Perhaps you could set mockedState.route to an object that has an equals function:
const mockedState = fromJS({
route: { equals: item => item === item },
});
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%2f53274746%2ftypeerror-routingstate-equals-is-not-a-function-jest-test-case%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
The problem is here:
const routingState = state.get('route');
Sense you didn't get the routingState,possible undefined, so you will get this above error message.So check the date of routingState.
And in the test file, pass mockedState to selectLocationState
selectLocationState(mockedState)
However,makeSelectLocationState function didn't have property.Maybe change to this:
const makeSelectLocationState = (state) => {}
TypeError: Cannot read property 'equals' of undefined. After making the changes I get this above error. @root
– Shwetank
Nov 13 '18 at 7:05
@Shwetank please provide the output of console.log(routingState) in makeSelectLocationState.
– Root
Nov 13 '18 at 7:07
The output of the console.log(routingState) is Map {size: 1, _root: ArrayMapNode, __ownerID: undefined, __hash: undefined, __altered: false} @root
– Shwetank
Nov 13 '18 at 7:22
@Shwetank while the type of routingState is Map,and Map actually don't have equals function.You can use this:routingState.toString() === prevRoutingState.toString() or use forEach to check every item of routingState.
– Root
Nov 13 '18 at 7:56
add a comment |
The problem is here:
const routingState = state.get('route');
Sense you didn't get the routingState,possible undefined, so you will get this above error message.So check the date of routingState.
And in the test file, pass mockedState to selectLocationState
selectLocationState(mockedState)
However,makeSelectLocationState function didn't have property.Maybe change to this:
const makeSelectLocationState = (state) => {}
TypeError: Cannot read property 'equals' of undefined. After making the changes I get this above error. @root
– Shwetank
Nov 13 '18 at 7:05
@Shwetank please provide the output of console.log(routingState) in makeSelectLocationState.
– Root
Nov 13 '18 at 7:07
The output of the console.log(routingState) is Map {size: 1, _root: ArrayMapNode, __ownerID: undefined, __hash: undefined, __altered: false} @root
– Shwetank
Nov 13 '18 at 7:22
@Shwetank while the type of routingState is Map,and Map actually don't have equals function.You can use this:routingState.toString() === prevRoutingState.toString() or use forEach to check every item of routingState.
– Root
Nov 13 '18 at 7:56
add a comment |
The problem is here:
const routingState = state.get('route');
Sense you didn't get the routingState,possible undefined, so you will get this above error message.So check the date of routingState.
And in the test file, pass mockedState to selectLocationState
selectLocationState(mockedState)
However,makeSelectLocationState function didn't have property.Maybe change to this:
const makeSelectLocationState = (state) => {}
The problem is here:
const routingState = state.get('route');
Sense you didn't get the routingState,possible undefined, so you will get this above error message.So check the date of routingState.
And in the test file, pass mockedState to selectLocationState
selectLocationState(mockedState)
However,makeSelectLocationState function didn't have property.Maybe change to this:
const makeSelectLocationState = (state) => {}
answered Nov 13 '18 at 6:56
RootRoot
1,513128
1,513128
TypeError: Cannot read property 'equals' of undefined. After making the changes I get this above error. @root
– Shwetank
Nov 13 '18 at 7:05
@Shwetank please provide the output of console.log(routingState) in makeSelectLocationState.
– Root
Nov 13 '18 at 7:07
The output of the console.log(routingState) is Map {size: 1, _root: ArrayMapNode, __ownerID: undefined, __hash: undefined, __altered: false} @root
– Shwetank
Nov 13 '18 at 7:22
@Shwetank while the type of routingState is Map,and Map actually don't have equals function.You can use this:routingState.toString() === prevRoutingState.toString() or use forEach to check every item of routingState.
– Root
Nov 13 '18 at 7:56
add a comment |
TypeError: Cannot read property 'equals' of undefined. After making the changes I get this above error. @root
– Shwetank
Nov 13 '18 at 7:05
@Shwetank please provide the output of console.log(routingState) in makeSelectLocationState.
– Root
Nov 13 '18 at 7:07
The output of the console.log(routingState) is Map {size: 1, _root: ArrayMapNode, __ownerID: undefined, __hash: undefined, __altered: false} @root
– Shwetank
Nov 13 '18 at 7:22
@Shwetank while the type of routingState is Map,and Map actually don't have equals function.You can use this:routingState.toString() === prevRoutingState.toString() or use forEach to check every item of routingState.
– Root
Nov 13 '18 at 7:56
TypeError: Cannot read property 'equals' of undefined. After making the changes I get this above error. @root
– Shwetank
Nov 13 '18 at 7:05
TypeError: Cannot read property 'equals' of undefined. After making the changes I get this above error. @root
– Shwetank
Nov 13 '18 at 7:05
@Shwetank please provide the output of console.log(routingState) in makeSelectLocationState.
– Root
Nov 13 '18 at 7:07
@Shwetank please provide the output of console.log(routingState) in makeSelectLocationState.
– Root
Nov 13 '18 at 7:07
The output of the console.log(routingState) is Map {size: 1, _root: ArrayMapNode, __ownerID: undefined, __hash: undefined, __altered: false} @root
– Shwetank
Nov 13 '18 at 7:22
The output of the console.log(routingState) is Map {size: 1, _root: ArrayMapNode, __ownerID: undefined, __hash: undefined, __altered: false} @root
– Shwetank
Nov 13 '18 at 7:22
@Shwetank while the type of routingState is Map,and Map actually don't have equals function.You can use this:routingState.toString() === prevRoutingState.toString() or use forEach to check every item of routingState.
– Root
Nov 13 '18 at 7:56
@Shwetank while the type of routingState is Map,and Map actually don't have equals function.You can use this:routingState.toString() === prevRoutingState.toString() or use forEach to check every item of routingState.
– Root
Nov 13 '18 at 7:56
add a comment |
route: ''
const routingState = state.get('route');
It looks like route is a string (an empty string). Strings do not have an equals method, so routingState.equals() doesn't exist.
Perhaps you could set mockedState.route to an object that has an equals function:
const mockedState = fromJS({
route: { equals: item => item === item },
});
add a comment |
route: ''
const routingState = state.get('route');
It looks like route is a string (an empty string). Strings do not have an equals method, so routingState.equals() doesn't exist.
Perhaps you could set mockedState.route to an object that has an equals function:
const mockedState = fromJS({
route: { equals: item => item === item },
});
add a comment |
route: ''
const routingState = state.get('route');
It looks like route is a string (an empty string). Strings do not have an equals method, so routingState.equals() doesn't exist.
Perhaps you could set mockedState.route to an object that has an equals function:
const mockedState = fromJS({
route: { equals: item => item === item },
});
route: ''
const routingState = state.get('route');
It looks like route is a string (an empty string). Strings do not have an equals method, so routingState.equals() doesn't exist.
Perhaps you could set mockedState.route to an object that has an equals function:
const mockedState = fromJS({
route: { equals: item => item === item },
});
answered Nov 13 '18 at 7:49
stonestone
4,5754059
4,5754059
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%2f53274746%2ftypeerror-routingstate-equals-is-not-a-function-jest-test-case%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