how to get the text of anchor tag in jest
up vote
1
down vote
favorite
<a href={LinkMappingUtility.getMappedWebUiLink('/#/dashboard')}
data-id="0"
className="nav-menu-item"
autoFocus="true">
{menuItem({ linkTitle: translate('sbDashboard', currentLanguage), icon: 'swn-home-icon' })}
this is the anchor tag inside that i have menu item text and i want the text in enzyme
My Code is :
test('all menu items display the correct text', () => {
const allMenuItemText = [
{ linkTitle: 'Dashboard', icon: 'swn-home-icon' },
{ linkTitle: 'Alerts', icon: 'swn-alerts-icon' },
{ linkTitle: 'Contact Management', icon: 'swn-home-icon'},
{ linkTitle: 'Reporting', icon: 'swn-home-icon' },
{ linkTitle: 'Solutions', icon: 'swn-home-icon' },
{ linkTitle: 'Integrations', icon: 'swn-home-icon' },
{ linkTitle: 'Account Settings', icon: 'swn-home-icon'},
{ linkTitle: 'Support & Training', icon: 'swn-home-icon' }
];
wrapper.find('.nav-menu-item').forEach((node, index) => {
expect(node.text()).toEqual(allMenuItemText[index].linkTitle);
})
output : here i am getting the empty string in return
javascript reactjs jestjs enzyme
add a comment |
up vote
1
down vote
favorite
<a href={LinkMappingUtility.getMappedWebUiLink('/#/dashboard')}
data-id="0"
className="nav-menu-item"
autoFocus="true">
{menuItem({ linkTitle: translate('sbDashboard', currentLanguage), icon: 'swn-home-icon' })}
this is the anchor tag inside that i have menu item text and i want the text in enzyme
My Code is :
test('all menu items display the correct text', () => {
const allMenuItemText = [
{ linkTitle: 'Dashboard', icon: 'swn-home-icon' },
{ linkTitle: 'Alerts', icon: 'swn-alerts-icon' },
{ linkTitle: 'Contact Management', icon: 'swn-home-icon'},
{ linkTitle: 'Reporting', icon: 'swn-home-icon' },
{ linkTitle: 'Solutions', icon: 'swn-home-icon' },
{ linkTitle: 'Integrations', icon: 'swn-home-icon' },
{ linkTitle: 'Account Settings', icon: 'swn-home-icon'},
{ linkTitle: 'Support & Training', icon: 'swn-home-icon' }
];
wrapper.find('.nav-menu-item').forEach((node, index) => {
expect(node.text()).toEqual(allMenuItemText[index].linkTitle);
})
output : here i am getting the empty string in return
javascript reactjs jestjs enzyme
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
<a href={LinkMappingUtility.getMappedWebUiLink('/#/dashboard')}
data-id="0"
className="nav-menu-item"
autoFocus="true">
{menuItem({ linkTitle: translate('sbDashboard', currentLanguage), icon: 'swn-home-icon' })}
this is the anchor tag inside that i have menu item text and i want the text in enzyme
My Code is :
test('all menu items display the correct text', () => {
const allMenuItemText = [
{ linkTitle: 'Dashboard', icon: 'swn-home-icon' },
{ linkTitle: 'Alerts', icon: 'swn-alerts-icon' },
{ linkTitle: 'Contact Management', icon: 'swn-home-icon'},
{ linkTitle: 'Reporting', icon: 'swn-home-icon' },
{ linkTitle: 'Solutions', icon: 'swn-home-icon' },
{ linkTitle: 'Integrations', icon: 'swn-home-icon' },
{ linkTitle: 'Account Settings', icon: 'swn-home-icon'},
{ linkTitle: 'Support & Training', icon: 'swn-home-icon' }
];
wrapper.find('.nav-menu-item').forEach((node, index) => {
expect(node.text()).toEqual(allMenuItemText[index].linkTitle);
})
output : here i am getting the empty string in return
javascript reactjs jestjs enzyme
<a href={LinkMappingUtility.getMappedWebUiLink('/#/dashboard')}
data-id="0"
className="nav-menu-item"
autoFocus="true">
{menuItem({ linkTitle: translate('sbDashboard', currentLanguage), icon: 'swn-home-icon' })}
this is the anchor tag inside that i have menu item text and i want the text in enzyme
My Code is :
test('all menu items display the correct text', () => {
const allMenuItemText = [
{ linkTitle: 'Dashboard', icon: 'swn-home-icon' },
{ linkTitle: 'Alerts', icon: 'swn-alerts-icon' },
{ linkTitle: 'Contact Management', icon: 'swn-home-icon'},
{ linkTitle: 'Reporting', icon: 'swn-home-icon' },
{ linkTitle: 'Solutions', icon: 'swn-home-icon' },
{ linkTitle: 'Integrations', icon: 'swn-home-icon' },
{ linkTitle: 'Account Settings', icon: 'swn-home-icon'},
{ linkTitle: 'Support & Training', icon: 'swn-home-icon' }
];
wrapper.find('.nav-menu-item').forEach((node, index) => {
expect(node.text()).toEqual(allMenuItemText[index].linkTitle);
})
output : here i am getting the empty string in return
javascript reactjs jestjs enzyme
javascript reactjs jestjs enzyme
edited Nov 11 at 9:18
asked Nov 9 at 8:58
Surin Ranjan Panda
62
62
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
I'm guessing just a typo, you meant to use a class selector?
// tag selector
wrapper.find('nav-menu-item') ...
// class selector
wrapper.find('.nav-menu-item') ...
no still i am getting empty string text() method is not returning the value
– Surin Ranjan Panda
Nov 11 at 9:19
@SurinRanjanPanda have you tried using a snapshot to cross-check how the anchor elements are loading? Based on edits to your question, I get the feeling we don’t have a minimal, complete, verifiable example to work from.
– stealththeninja
Nov 11 at 23:37
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
I'm guessing just a typo, you meant to use a class selector?
// tag selector
wrapper.find('nav-menu-item') ...
// class selector
wrapper.find('.nav-menu-item') ...
no still i am getting empty string text() method is not returning the value
– Surin Ranjan Panda
Nov 11 at 9:19
@SurinRanjanPanda have you tried using a snapshot to cross-check how the anchor elements are loading? Based on edits to your question, I get the feeling we don’t have a minimal, complete, verifiable example to work from.
– stealththeninja
Nov 11 at 23:37
add a comment |
up vote
2
down vote
I'm guessing just a typo, you meant to use a class selector?
// tag selector
wrapper.find('nav-menu-item') ...
// class selector
wrapper.find('.nav-menu-item') ...
no still i am getting empty string text() method is not returning the value
– Surin Ranjan Panda
Nov 11 at 9:19
@SurinRanjanPanda have you tried using a snapshot to cross-check how the anchor elements are loading? Based on edits to your question, I get the feeling we don’t have a minimal, complete, verifiable example to work from.
– stealththeninja
Nov 11 at 23:37
add a comment |
up vote
2
down vote
up vote
2
down vote
I'm guessing just a typo, you meant to use a class selector?
// tag selector
wrapper.find('nav-menu-item') ...
// class selector
wrapper.find('.nav-menu-item') ...
I'm guessing just a typo, you meant to use a class selector?
// tag selector
wrapper.find('nav-menu-item') ...
// class selector
wrapper.find('.nav-menu-item') ...
answered Nov 9 at 9:31
stealththeninja
1,65811324
1,65811324
no still i am getting empty string text() method is not returning the value
– Surin Ranjan Panda
Nov 11 at 9:19
@SurinRanjanPanda have you tried using a snapshot to cross-check how the anchor elements are loading? Based on edits to your question, I get the feeling we don’t have a minimal, complete, verifiable example to work from.
– stealththeninja
Nov 11 at 23:37
add a comment |
no still i am getting empty string text() method is not returning the value
– Surin Ranjan Panda
Nov 11 at 9:19
@SurinRanjanPanda have you tried using a snapshot to cross-check how the anchor elements are loading? Based on edits to your question, I get the feeling we don’t have a minimal, complete, verifiable example to work from.
– stealththeninja
Nov 11 at 23:37
no still i am getting empty string text() method is not returning the value
– Surin Ranjan Panda
Nov 11 at 9:19
no still i am getting empty string text() method is not returning the value
– Surin Ranjan Panda
Nov 11 at 9:19
@SurinRanjanPanda have you tried using a snapshot to cross-check how the anchor elements are loading? Based on edits to your question, I get the feeling we don’t have a minimal, complete, verifiable example to work from.
– stealththeninja
Nov 11 at 23:37
@SurinRanjanPanda have you tried using a snapshot to cross-check how the anchor elements are loading? Based on edits to your question, I get the feeling we don’t have a minimal, complete, verifiable example to work from.
– stealththeninja
Nov 11 at 23:37
add a comment |
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%2f53222566%2fhow-to-get-the-text-of-anchor-tag-in-jest%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