cypress

Handling Hover over menu's using Cypress

ぃ、小莉子 提交于 2019-12-07 05:41:59
问题 I recently stumbled upon the e2e tool - Cypress.io. I'm currently doing a POC for the firm I work with for e2e testing of a react app. It has a hover over menu like most of the web apps have now. An example : URL : Fmovies I was trying to click a menu item from this hover over but the test fails saying that the display is set to none . In Selenium, we use the moveElement approach to go to this element, and then do whatever we need to do. However, I'm failing to do so using Cypress.

Check if an error has been written to the console

时光总嘲笑我的痴心妄想 提交于 2019-12-07 01:05:52
问题 I'm trying to find a way to check if an error has been written to the console when running a cypress unit test. I know how to log something to the console cy.log('log this to the console'); but not how to check if an error has been written to it. any suggestions how to read errors from the (browser) console log? note: probably not the "smart" way to test but sometimes my js libraries which I use would "complain" and write the errors to the browser log. this is to simplify testing. 回答1: Edit:

Assert that element is not actionable in Cypress

夙愿已清 提交于 2019-12-06 19:24:02
问题 If an element is not actionable on the page (in this case, covered by another element) and you try to click it, Cypress will show an error like this: CypressError: Timed out retrying: cy.click() failed because this element: <span>...</span> is being covered by another element: Great! But is there any way to assert that this is the case, aka that the element cannot be clicked? This doesn't work: should.not.exist - the element does exist should.be.disabled - the element is not disabled should

How does module resolution in TypeScript work for global values (i.e. describe)?

旧街凉风 提交于 2019-12-06 18:38:05
问题 While using jest on its own the corresponding typescript definitions got detected right after installing @types/jest . I then started to implement integration tests with cypress. Since cypress is using mocha, I now incorrectly see references of mocha type definitions inside my jest tests. In fact, a number of overlapping type definitions are detected. For instance, describe seems to be defined in a number of files. I even tried to implement my own typing for describe pointing to jest.

mocking server for SSR react app e2e tests with cypress.io

人走茶凉 提交于 2019-12-06 14:43:50
I'm building a single page web application (SPA) with server side rendering (SSR). We have a node backend API which is called both from the node server during SSR and from the browser after initial rendering. I want to write e2e tests that configures API responses (like with nock ) and work both with browser calls and SSR server calls. some pseudo-code : it('loads some page (SSR mode)', () => { mockAPI.response('/some-path', {text: "some text"}); // here i configure the mock server response browser.load('/some-other-page'); // hit server for SSR response expect(myPage).toContain('some text');

Cypress could not verify that the server set as your 'baseUrl' is running:

倾然丶 夕夏残阳落幕 提交于 2019-12-06 11:09:43
I can reach from my computer with web browser to xxxx.com:8089 which is running on a container too but different remote machine. Everything is fine. My cypress.json "baseUrl": " http://xxxx.com:8089 " is this. I am trying to run docker container to run tests with Cypress : docker run --rm --name burak --ipc="host" -w /hede -v /Users/kurhanb/Desktop/nameoftheProject:/hede' cypress /bin/bash -c cypress run --browser chrome && chmod -R 777 . --reporter mochawesome --reporter-options --reportDir=Users/kurhanb/Desktop/CypressTest overwrite=false It gives me : Cypress could not verify that the

How to emulate vuex store action with cypress

帅比萌擦擦* 提交于 2019-12-06 10:29:41
I have a login process where after sending a request to the server and getting a response, I do this: this.$auth.setToken(response.data.token); this.$store.dispatch("setLoggedUser", { username: this.form.username }); Now I'd like to emulate this behavior when testing with cypress, so i don't need to actually login each time I run a test. So I've created a command: Cypress.Commands.add("login", () => { cy .request({ method: "POST", url: "http://localhost:8081/api/v1/login", body: {}, headers: { Authorization: "Basic " + btoa("administrator:12345678") } }) .then(resp => { window.localStorage

Cypress expect element to contain one string or another string

两盒软妹~` 提交于 2019-12-06 07:50:19
I'm trying to do some Cypress assertions to see whether or not it contains one or another string. It can be in English or Spanish, so either one should pass the test. cy.get(el).should('contain', 'submit').or('contain', 'enviar') obviously doesnt work. const runout = ['submit', 'enviar'] const el = '[data-test=btn-submit]' function checkArray(arr, el) { for(let i = 0; i < arr.length; i++) { if(cy.get(el).contains(arr[i])) { return true } else { if (i === arr.length) { return false } } } } cy.expect(checkArray(runout,el)).to.be.true fails the test, still checking both strings. You can try a

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

不想你离开。 提交于 2019-12-06 07:13:46
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. function getViewport() { var viewport = {} cy.document().then((doc) => { let width = Cypress.$(doc)

Detailed Reporting Cypress/Mochawesome

不羁的心 提交于 2019-12-06 04:23:00
问题 Has anyone had much experience of generating good detailed reports from Cypress tests using Mochawesome as the report engine? I've followed the info on the Mochawesome GIT page but what I get is rather dull!! I'd like to be able to include the odd screen-shot and the output from the assertions - here's the current cypress.json file...... { "projectId": "haw8v6", "baseUrl": "https://obmng.dbm.guestline.net/", "chromeWebSecurity": false, "reporter" : "mochawesome", "reporterOptions" : {