forked from cypress-io/cypress-react-unit-test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
counter-spec.js
40 lines (36 loc) · 825 Bytes
/
counter-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
33
34
35
36
37
38
39
40
/// <reference types="cypress" />
/// <reference types="../../lib" />
import React from 'react'
import { mount } from 'cypress-react-unit-test'
import { Counter } from './counter.jsx'
/* eslint-env mocha */
describe('Counter', () => {
it('counts clicks', () => {
mount(<Counter />)
cy.contains('count: 0')
.click()
.contains('count: 1')
.click()
.contains('count: 2')
})
it('counts clicks 2', () => {
mount(<Counter />)
cy.contains('count: 0')
.click()
.contains('count: 1')
.click()
.contains('count: 2')
})
})
describe('Counter mounted before each test', () => {
beforeEach(() => {
mount(<Counter />)
})
it('goes to 3', () => {
cy.contains('count: 0')
.click()
.click()
.click()
.contains('count: 3')
})
})