forked from cypress-io/cypress-example-recipes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
first-spec.js
32 lines (28 loc) · 888 Bytes
/
first-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('First spec', () => {
// just for our sake we can verify the object
const expectedTodo = {
userId: 1,
id: 1,
title: 'delectus aut autem',
completed: false,
}
it('1 - stores the value', () => {
// we could visit a page, save a value from the DOM
// or make a network request and save the response
const url = 'https://jsonplaceholder.cypress.io/todos/1'
cy.request(url).its('body').then((todo) => {
expect(todo).to.be.an('object')
expect(todo).to.deep.equal(expectedTodo)
cy.task('setItem', {
name: 'todo',
value: todo,
})
})
})
it('2 - has the saved item in the next test', () => {
// if the previous test has passed, we should have
// the item stored in the plugin file
cy.task('getItem', 'todo').should('deep.equal', expectedTodo)
})
})