Skip to content
This repository was archived by the owner on Mar 5, 2022. It is now read-only.

Commit f8734b0

Browse files
committed
add example with react-boostrap, closes #99
1 parent b6eb171 commit f8734b0

File tree

4 files changed

+194
-0
lines changed

4 files changed

+194
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ Spec | Description
127127
[timers](cypress/component/advanced/timers) | Testing components that set timers, adopted from [ReactJS Testing recipes](https://reactjs.org/docs/testing-recipes.html#timers)
128128
[tutorial](cypress/component/advanced/tutorial) | A few tests adopted from [ReactJS Tutorial](https://reactjs.org/tutorial/tutorial.html)
129129
[portal](cypress/component/advanced/portal) | Component test for `ReactDOM.createPortal` feature
130+
[react-bootstrap](cypress/component/advanced/react-bootstrap) | Confirms [react-bootstrap](https://react-bootstrap.github.io/) components are working
130131
<!-- prettier-ignore-end -->
131132

132133
### Large examples
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React from 'react'
2+
import { Dropdown } from 'react-bootstrap'
3+
import { mount } from 'cypress-react-unit-test'
4+
5+
class UserControls extends React.Component {
6+
constructor(props) {
7+
super(props)
8+
this.state = {}
9+
}
10+
11+
render() {
12+
return (
13+
<Dropdown>
14+
<Dropdown.Toggle>Top Toggle</Dropdown.Toggle>
15+
<Dropdown.Menu>
16+
<li>First</li>
17+
<li>Second</li>
18+
<li>Third</li>
19+
</Dropdown.Menu>
20+
</Dropdown>
21+
)
22+
}
23+
}
24+
25+
UserControls.displayName = 'UserControls'
26+
27+
// https://github.com/bahmutov/cypress-react-unit-test/issues/99
28+
describe('react-bootstrap Dropdown', () => {
29+
it('works', () => {
30+
mount(<UserControls />, {
31+
cssFile: 'node_modules/bootstrap/dist/css/bootstrap.min.css',
32+
})
33+
cy.contains('Top Toggle').click()
34+
cy.contains('li', 'First').should('be.visible')
35+
cy.get('li').should('have.length', 3)
36+
})
37+
})

package-lock.json

Lines changed: 154 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"axios": "0.18.1",
6464
"babel-loader": "8.0.6",
6565
"babel-plugin-module-resolver": "4.0.0",
66+
"bootstrap": "4.4.1",
6667
"common-tags": "1.8.0",
6768
"css-loader": "2.1.1",
6869
"cypress": "4.5.0",
@@ -74,6 +75,7 @@
7475
"pretty": "2.0.0",
7576
"prop-types": "15.7.2",
7677
"react": "^16.13.1",
78+
"react-bootstrap": "1.0.1",
7779
"react-dom": "^16.13.1",
7880
"react-google-maps": "9.4.5",
7981
"react-router": "6.0.0-alpha.1",

0 commit comments

Comments
 (0)