Problem description
CypressError: Timed out retrying: Expected to find content: 'mm' within the element: but never did.
I have mounted the component on cypress with mock data. Then I tried to get an element using below source code and receive the above error:
cy.get('#edit-highlights-form1').contains('2m');
Current situation
I have a vue.js application which contains a component and it consumes data from an API. Please find the source code below that I tried to write unit test for that component using Cypress.
Code:
describe('Edit highlights component ', () => {
beforeEach(mountVue({
template,
components,
data
}))
it('Stub the mock data to the component edit highlights', () => {
cy.server();
cy.route({
method: 'GET',
url: '/drupal/api/v1/getHighlightData/*',
response: data().highlightModel
}).as('apiHighligihtData');
mountVue({
template,
components,
data
});
cy.get('#edit-highlights-form1').contains('2m');
});
});
I got the tutorial from https://github.com/bahmutov/cypress-vue-unit-test/blob/master/cypress/integration/ajax-list-spec.js