This repository was archived by the owner on Mar 5, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +33
-2
lines changed
Expand file tree Collapse file tree 6 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,8 @@ Look at the examples in [cypress/component](cypress/component) folder. Here is t
6363Spec | Description
6464--- | ---
6565[ alert-spec.js] ( cypress/component/basic/alert-spec.js ) | Component tries to use ` window.alert `
66- [ counter-spec.js] ( cypress/component/basic/counter-spec.js ) | Counter component that uses ` this.state `
66+ [ counter-set-state] ( cypress/component/basic/counter-set-state ) | Counter component that uses ` this.state `
67+ [ counter-use-hooks] ( cypress/component/basic/counter-use-hooks ) | Counter component that uses ` useState ` hook
6768[ emotion-spec.js] ( cypress/component/basic/emotion-spec.js ) | Confirms the component is using ` @emotion/core ` and styles are set
6869[ error-boundary-spec.js] ( cypress/component/basic/error-boundar-spec.js ) | Checks if an error boundary component works
6970[ pure-component-spec.js] ( cypress/component/basic/pure-component.spec.js ) | Tests stateless component
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change 1+ import React from 'react'
2+ import { mount } from 'cypress-react-unit-test'
3+ import Counter from './counter.jsx'
4+
5+ describe ( 'Counter using hooks' , ( ) => {
6+ it ( 'works' , ( ) => {
7+ mount ( < Counter /> )
8+ cy . contains ( 'You clicked 0 times' )
9+ cy . contains ( 'Click me' )
10+ . click ( )
11+ . click ( )
12+ . click ( )
13+ cy . contains ( 'You clicked 3 times' )
14+ } )
15+ } )
Original file line number Diff line number Diff line change 1+ import React , { useState } from 'react'
2+
3+ // example from https://reactjs.org/docs/hooks-state.html
4+ function Counter ( ) {
5+ // Declare a new state variable, which we'll call "count"
6+ const [ count , setCount ] = useState ( 0 )
7+
8+ return (
9+ < div >
10+ < p > You clicked { count } times</ p >
11+ < button onClick = { ( ) => setCount ( count + 1 ) } > Click me</ button >
12+ </ div >
13+ )
14+ }
15+
16+ export default Counter
Original file line number Diff line number Diff line change 22/// <reference types="../../lib" />
33import { Transpiled } from './transpiled.jsx'
44import React from 'react'
5- import ReactDom from 'react-dom'
65import { mount } from 'cypress-react-unit-test'
76
87/* eslint-env mocha */
You can’t perform that action at this time.
0 commit comments