cypress

Cypress: Test if element does not exist

隐身守侯 提交于 2019-12-08 22:25:42
问题 I want to be able to click on a check box and test that an element is no longer in the DOM in Cypress. Can someone suggest how you do it? //This is the Test when the check box is clicked and the element is there cy.get('[type="checkbox"]').click(); cy.get('.check-box-sub-text').contains('Some text in this div.') I want to do the opposite of the test above. So when I click it again the div with the class should not be in the DOM. 回答1: Well this seems to work, so it tells me I have some more to

How do you check the equality of the inner text of a element using cypress?

懵懂的女人 提交于 2019-12-08 17:13:49
问题 I have a div that has another div inside of it and I want to check the equality of the inner text of the div. I have figured out how to do it using the invoke('text') function, but i am wondering if that is the best way. So my question is: how do you check the equality of the inner text of a element using cypress? it('the channel name should contain be Anakin Skywaler', () => { //This works but can we be more specific with our selector cy.get("[data-test-id='Skywalker,Anakin']").should(

Cypress.io - Assert no XHR requests to URL?

▼魔方 西西 提交于 2019-12-08 15:00:36
问题 When testing with cypress.io, is there a good way to assert that no XHR requests were made to a given URL? I want to assert that a new foo is added when the "Save" button is clicked, but not when the "Cancel" button is clicked. Something like this: cy.route('POST', '/foos').as('postFoo'); cy.get('.cancel-button').click(); cy.route('@postFoo').should('not.have.been.called'); // (magic imaginary syntax!) I've tried setting up the cy.route with an onRequest callback that does an assert.fail, but

How to set cookies within Cypress testing?

∥☆過路亽.° 提交于 2019-12-08 12:37:17
问题 this example taken from the Cypress documentation won't work properly: cy.getCookies().should('be.empty'); cy.setCookie('session_id', '189jd09sufh33aaiidhf99d09'); cy.getCookie('session_id').should('have.property', 'value', '189jd09sufh33aaiidhf99d09'); Every time I try to setCookie(), it appears to set it without issue but always returns this when I call getCookies(): $Chainer {chainerId: "chainer18", firstCall: false} chainerId: "chainer18" firstCall: false __proto__: Object Is there

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

你离开我真会死。 提交于 2019-12-07 23:53:15
问题 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

cypress ParseError on css content

流过昼夜 提交于 2019-12-07 14:47:52
问题 I am new to Cypress for javascrpt testing. I'm testing a basic react app with css. Whether I import css directly or use css modules, the test always fails with: ul { ^ ParseError: Unexpected token That ParseError is shown in the cypress test runner. It also has this text in the test runner sidebar: This occurred while Cypress was compiling and bundling your test code. This is usually caused by: A missing file or dependency A syntax error in the file or one of its dependencies Fix the error in

Logging into a Django server with Cypress.io programmatically (without using UI)

為{幸葍}努か 提交于 2019-12-07 10:45:10
问题 Must be missing something obvious but I am very much stuck on logins into Django due to its CSRF protection. I looked Check out our example recipes using cy.getCookie() to test logging in using HTML web forms but that really doesn't help that much if the first thing it recommends is disabling CSRF. What Django wants: This is what a normal, CSRF-protected, Django login view is expecting in its incoming POST data: csrfmiddlewaretoken

Cypress test: is .contains() equivalent to should('contain')?

倖福魔咒の 提交于 2019-12-07 08:30:40
问题 Is this: cy.get('[name=planSelect]').contains(dummyPlan) equivalent to this: cy.get('[name=planSelect]').should('contain', dummyPlan) And if so, which is preferred? The first is more of an implicit assertion, but it's shorter and cleaner to my mind. Follow-up question: After looking around to see how best to select elements for e2e testing I found that the Cypress docs recommend using data-cy attributes. Is there a reason this would be better than just adding name attributes to the markup?

How to wait for two parallel XHR requests in Cypress

本小妞迷上赌 提交于 2019-12-07 07:20:47
问题 I know that it is possible to wait for multiple XHR requests on the same url as shown here. However, I would like to wait for two requests running in parallel. cy.wait('@users') cy.wait('@users') When I add two waits as shown above, the second one sometimes timeouts when they finish very closely together, as it basically misses the XHR. CypressError: Timed out retrying: cy.wait() timed out waiting 30000ms for the 1st response to the route: 'users'. No response ever occurred. I do not like the

Cypress: Stub response for same route with three different responses

为君一笑 提交于 2019-12-07 06:40:21
问题 I have a single endpoint in the application. We hit the same api for each request with different action in the params. URL: /application/api Sample Request Payload 1: { "action": "CARD_TRANSACTION_HISTORY", "data": { "date_from": "2018-12-01", "date_to": "2018-12-31", "total": 5 }, "meta": {} } Sample Request Payload 2: { "action": "CARD_BALANCE", "data": { "date_from": "2018-12-01", "date_to": "2018-12-31", "total": 5 }, "meta": {} } Sample Request Payload 3: { "action": "CURRENCY_RATES",