forked from cypress-io/cypress-example-recipes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusing-task-spec.js
32 lines (30 loc) · 1019 Bytes
/
using-task-spec.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" />
describe('Two domains', () => {
it('visits 1nd domain', () => {
cy.visit('https://www.cypress.io/')
// there are several GitHub links on the page, make sure
// to use the selector that returns a single item
cy.get('header [aria-label="Check out our github page"]')
.should('have.length', 1)
// from the jQuery wrapping <a href="https://github.io ..." />
// get the "href" value
.invoke('attr', 'href')
.then((url) => {
// save the value in the plugins process
// that is preserved between browser page reloads
expect(url).to.be.a('string')
cy.task('saveUrl', url)
})
})
it('visits 2nd domain', () => {
// we assume the first test has finished
// and stored the url
cy.task('getUrl')
.then((url) => {
expect(url).to.be.a('string')
cy.visit(url)
})
// confirm the GitHub page loads
cy.contains('[data-hovercard-type=organization]', 'cypress-io').should('be.visible')
})
})