cypress

Using cypress with vuetify

非 Y 不嫁゛ 提交于 2020-01-24 08:25:10
问题 I have a Vue.js project (Nuxt.js) and as UI I use the Vuetify. For e2e testing I use the Cypress. Below is my scenarios of test in Cypress: I have a problem while creating test for page where I use v-autocomplete component. The problem is that I can't use Vuetify native classes to get the element I want to test. below is an example with data-cy selector <v-autocomplete v-model="model" :items="items" item-text="Description" item-value="API" label="Public APIs" placeholder="Start typing to

Save local storage across tests to avoid re-authentication

橙三吉。 提交于 2020-01-24 00:34:07
问题 I'm wondering if it is possible to save the state of localStorage across tests. Mainly because I want to avoid re-authentication on each test. I realize that I can create a command that sends an API request to our backend to avoid going through the auth flow but for various reasons this won't work in my situation. I am asking if it possible to have a workflow like this: Go to login page: Authenticate get back response and save session to local storage Persist local storage somehow... Go

Cypress: Get token from API then save in local storage and use in another API's header then return the response body of the 2nd API

…衆ロ難τιáo~ 提交于 2020-01-16 11:25:34
问题 I have an API (let's call it getToken ) to generate a token in its response body. I then call that token and store in the header of another API (let's call it returnBody ). It makes sense to use localStorage for the getToken API as this token is re-usable for multiple API's. However, I am having doubts using localStorage if I need to return / display the response body of the succeeding API's such as returnBody . Inside the API's function/command, it logs the response body. However, when I

how to click the link in cypress

依然范特西╮ 提交于 2020-01-15 15:33:43
问题 How to click this link with cypress? <a href="#" aria-disabled="false" class="button "> <span class="icon icon-chevron-down " aria-hidden="true"> </span> <span class="screen-reader-only"> chevron-down_icon </span> </a> 回答1: That's pretty easy, the documentation of Cypress would help you as wel: https://docs.cypress.io/api/commands/click.html#Command-Log . But I'll help you too. I did the assumption that this is the only hyperlink on the page: cy.get('a') .click() If it is not the only one you

how to click the link in cypress

那年仲夏 提交于 2020-01-15 15:32:57
问题 How to click this link with cypress? <a href="#" aria-disabled="false" class="button "> <span class="icon icon-chevron-down " aria-hidden="true"> </span> <span class="screen-reader-only"> chevron-down_icon </span> </a> 回答1: That's pretty easy, the documentation of Cypress would help you as wel: https://docs.cypress.io/api/commands/click.html#Command-Log . But I'll help you too. I did the assumption that this is the only hyperlink on the page: cy.get('a') .click() If it is not the only one you

how to click the link in cypress

孤街浪徒 提交于 2020-01-15 15:32:35
问题 How to click this link with cypress? <a href="#" aria-disabled="false" class="button "> <span class="icon icon-chevron-down " aria-hidden="true"> </span> <span class="screen-reader-only"> chevron-down_icon </span> </a> 回答1: That's pretty easy, the documentation of Cypress would help you as wel: https://docs.cypress.io/api/commands/click.html#Command-Log . But I'll help you too. I did the assumption that this is the only hyperlink on the page: cy.get('a') .click() If it is not the only one you

How to stop loop in cypress

筅森魡賤 提交于 2020-01-14 19:12:50
问题 I have a loop checking 40 items. I want to stop my loop, when I am finding the first element, which > 0 This is my code var genArr = Array.from({ length: 40 }, (v, k) => k + 1); cy.wrap(genArr).each((index) => { cy.get('.list-item').eq(index - 1).find('.number') .invoke('text') .then(text => { const pendingCount = text; cy.get('.list-item').eq(index - 1).click(); cy.get('.list-table').find('.list-table-list-item') .should('have.length', pendingCount); if (text > 0) break }); }); }); But I

How to stop loop in cypress

我怕爱的太早我们不能终老 提交于 2020-01-14 19:11:08
问题 I have a loop checking 40 items. I want to stop my loop, when I am finding the first element, which > 0 This is my code var genArr = Array.from({ length: 40 }, (v, k) => k + 1); cy.wrap(genArr).each((index) => { cy.get('.list-item').eq(index - 1).find('.number') .invoke('text') .then(text => { const pendingCount = text; cy.get('.list-item').eq(index - 1).click(); cy.get('.list-table').find('.list-table-list-item') .should('have.length', pendingCount); if (text > 0) break }); }); }); But I

Do I need a unit-testing framework if I'm already using Cypress in a Vue.js app?

扶醉桌前 提交于 2020-01-14 09:21:10
问题 When scaffolding a new project with the Vue.js CLI, it offers a choice of both unit-testing and E2E-testing frameworks. Unit-testing functionality is perfectly adequate in Cypress. My question, then: is there an advantage to using a distinct unit-testing framework if I'm already using Cypress? 回答1: There is a third-party adapter made by a Cypress contributor here called cypress-vue-unit-test(along with unit-test adapters for other popular frameworks). You should check that out and see if it

How to return dimensions of document in Cypress for use in test later

断了今生、忘了曾经 提交于 2020-01-13 19:43:07
问题 I have a function in Cypress support/index.js that is meant to get the dimensions of the cy.document outerWidth and outerHeight , then return them for future use in a test. My problem is that when the test runs and the values are compared with others the assertion says the values are NaN . I checked by console logging the value at the point of the assertion and it was empty, so I must be doing something wrong, I'm just not sure what. My function is below, any help gratefully received, thanks.