-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathurl.cy.js
32 lines (29 loc) · 922 Bytes
/
url.cy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/// <reference types="cypress" />
// @ts-check
import '../../src'
describe('cy.url support', () => {
it('checks if url contains a give string (it does)', () => {
cy.visit('cypress/index.html')
cy.url().should('include', 'index.html').and('include', 'localhost')
cy.url()
.if('includes', 'index.html')
.log('includes index.html')
.then(cy.spy().as('if'))
.else()
.then(cy.spy().as('else'))
cy.get('@if').should('have.been.called')
cy.get('@else').should('not.have.been.called')
})
it('url does not contain a string', () => {
cy.visit('cypress/index.html')
cy.url()
.if('includes', 'acme.co')
.log('running on production')
.then(cy.spy().as('if'))
.else()
.log('running NOT on production')
.then(cy.spy().as('else'))
cy.get('@else').should('have.been.called')
cy.get('@if').should('not.have.been.called')
})
})