Skip to content

Commit 04bd3f1

Browse files
chore: remove todomvc testing + other outdated docs / references found (#32694)
1 parent 79cf6dd commit 04bd3f1

File tree

25 files changed

+17
-377
lines changed

25 files changed

+17
-377
lines changed

.circleci/src/pipeline/@pipeline.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2813,13 +2813,6 @@ jobs:
28132813
browser: chrome
28142814
executor: << parameters.executor >>
28152815

2816-
test-binary-against-todomvc-firefox:
2817-
<<: *defaults
2818-
steps:
2819-
- test-binary-against-repo:
2820-
repo: cypress-example-todomvc
2821-
browser: firefox
2822-
28232816
test-binary-against-cypress-realworld-app:
28242817
<<: *defaults
28252818
resource_class: medium+

.circleci/src/pipeline/workflows/@main.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -392,10 +392,6 @@ linux-x64:
392392
filters: *mainBuildFilters
393393
requires:
394394
- get-published-artifacts
395-
- test-binary-against-todomvc-firefox:
396-
filters: *mainBuildFilters
397-
requires:
398-
- get-published-artifacts
399395
- test-binary-against-cypress-realworld-app:
400396
context: test-runner:cypress-record-key
401397
filters: *mainBuildFilters
@@ -782,10 +778,6 @@ linux-x64-contributor:
782778
filters: *mainBuildFilters
783779
requires:
784780
- get-published-artifacts
785-
- test-binary-against-todomvc-firefox:
786-
filters: *mainBuildFilters
787-
requires:
788-
- get-published-artifacts
789781
- test-binary-against-cypress-realworld-app:
790782
context: test-runner:cypress-record-key
791783
filters: *mainBuildFilters

guides/release-process.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ _Note: It is advisable to notify the team that the `develop` branch is locked do
193193
24. If utilizing the `SKIP_RELEASE_CHANGELOG_VALIDATION_FOR_BRANCHES` to override and skip changelog validation for this release, change its value as needed or delete it from CircleCI so that subsequent releases and PRs will go through changelog validation.
194194
195195
25. Check all `cypress-test-*` and `cypress-example-*` repositories, and if there is a branch named `x.y.z` for testing the features or fixes from the newly published version `x.y.z`, update that branch to refer to the newly published NPM version in `package.json`. Then, get the changes approved and merged into that project's main branch. For projects without a `x.y.z` branch, you can go to the Renovate dependency issue and check the box next to `Update dependency cypress to X.Y.Z`. It will automatically create a PR. Once it passes, you can merge it. Try updating at least the following projects:
196-
- [cypress-example-todomvc](https://github.com/cypress-io/cypress-example-todomvc/issues/99)
197196
- [cypress-realworld-app](https://github.com/cypress-io/cypress-realworld-app/issues/41)
198197
- [cypress-example-recipes](https://github.com/cypress-io/cypress-example-recipes/issues/225)
199198
Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1 @@
1-
# Mocking context around the component
2-
3-
- [App-spec.js](App-spec.js) tests [App.jsx](App.jsx) that has a context provider [context.js](context.js) around [Toolbar.jsx](Toolbar.jsx)
4-
5-
We can also create children elements with mock context around them right from the test file. See [Mock-context-spec.js](Mock-context-spec.js) file.
6-
7-
```js
8-
import { mount } from '@cypress/react'
9-
import { ThemeContext } from './context'
10-
import { Toolbar } from './Toolbar.jsx'
11-
12-
it('passes given value', () => {
13-
mount(
14-
<ThemeContext.Provider value="mocked">
15-
<Toolbar />
16-
</ThemeContext.Provider>,
17-
)
18-
// confirm "mocked" value is passed to the Toolbar
19-
})
20-
```
21-
22-
![Mocked context screenshot](images/mock-context.png)
23-
24-
For more complex context mock example, see [bahmutov/sudoku](https://github.com/bahmutov/sudoku) repository.
1+
# App

npm/react/cypress/component/advanced/custom-command/spec.cy.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import React from 'react'
44
import { mount } from '@cypress/react'
55

6-
// https://github.com/bahmutov/@cypress/react/issues/184
76
Cypress.Commands.add('myMount', () => {
87
return mount(<div>My mount</div>)
98
})
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
# testing React hooks
2-
3-
- [counter-with-hooks.spec.js](counter-with-hooks.spec.js) and [counter2-with-hooks.spec.js](counter2-with-hooks.spec.js) test React components that uses hooks
1+
# Hooks
Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1 @@
1-
# Mocking CommonJS modules
2-
3-
Imagine your component is importing a CommonJS module from `node_modules` that you want to mock from the test. You can mock the methods by `require` that module and mocking its methods using [cy.stub](https://on.cypress.io/stub)
4-
5-
## When importing the entire module
6-
7-
Mock its methods from the test by using `require`
8-
9-
```js
10-
// component code
11-
import axios from 'axios'
12-
axios.get('...')
13-
// spec code, important to use `require` ⚠️
14-
const Axios = require('axios')
15-
cy.stub(Axios, 'get')
16-
```
17-
18-
See [1-users.jsx](./1-users.jsx) and [1-users.spec.js](./1-users.spec.js) files.
19-
20-
## When importing a named export
21-
22-
Mock this method from the test by using `require`
23-
24-
```js
25-
// component code only imports "get" from the module
26-
import { get } from 'axios'
27-
get('...')
28-
// spec code, important to use `require` ⚠️
29-
const Axios = require('axios')
30-
cy.stub(Axios, 'get')
31-
```
32-
33-
See [2-users-named.jsx](./2-users-named.jsx) and [2-users-named.spec.js](./2-users-named.spec.js) files.
34-
35-
## Using wrapper module
36-
37-
Mock any methods using `import` from the spec file.
38-
39-
You can also wrap module from `node_modules` and mock the wrap, and in this case the spec file can use `import` statements
40-
41-
```js
42-
// wrapper code
43-
export * from 'axios'
44-
// component code
45-
// import wrapped Axios method
46-
import { get } from './axios-api'
47-
// spec code can use "import"
48-
import * as Axios from './axios-api'
49-
```
50-
51-
![Mock wrapped Axios](./images/mock-axios-wrap.png)
52-
53-
See [3-users-api.jsx](./3-users-api.jsx) and [3-users-api.spec.js](./3-users-api.spec.js) files.
1+
# Mocking CommonJS modules
Lines changed: 1 addition & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1 @@
1-
Can we mock an import used in the component under test?
2-
3-
See [sinon.js discussion](https://github.com/sinonjs/sinon/issues/1121)
4-
5-
## Solution
6-
7-
In babel configuration file, add one more plugin
8-
9-
```js
10-
// https://babeljs.io/docs/en/babel-plugin-transform-modules-commonjs
11-
// loose ES6 modules allow us to dynamically mock imports during tests
12-
;[
13-
'@babel/plugin-transform-modules-commonjs',
14-
{
15-
loose: true,
16-
},
17-
]
18-
```
19-
20-
The ES6 exports and imports then will be a plain object then
21-
22-
```js
23-
// when loose: true
24-
// each ES6 export is made using plain objet
25-
var exports = { foo: 'bar' }
26-
// which we can overwrite later
27-
28-
// when loose: false
29-
// each ES6 export is made using
30-
// Object.defineProperty(exports, { value: ..., configurable: false })
31-
// which we cannot change
32-
```
33-
34-
We can overwrite a property like this
35-
36-
```js
37-
// component imports and uses greeting
38-
// like this
39-
// import {greeting} from './greeting'
40-
import Component from './component'
41-
import * as GreetingModule from './greeting'
42-
it('shows mock greeting', () => {
43-
// stub property on the loaded ES6 module using cy.stub
44-
// which will be restored after the test automatically
45-
cy.stub(GreetingModule, 'greeting', 'test greeting')
46-
mount(<Component />)
47-
cy.contains('h1', 'test greeting').should('be.visible')
48-
})
49-
```
50-
51-
## PizzaProps
52-
53-
If the component is using `defaultProps` to pass a method to call, you can stub it, see [PizzaProps.js](PizzaProps.js) and [PizzaProps.spec.js](PizzaProps.spec.js)
54-
55-
```js
56-
import PizzaProps from './PizzaProps'
57-
cy.stub(PizzaProps.defaultProps, 'fetchIngredients').resolves(...)
58-
```
59-
60-
## RemotePizza
61-
62-
Even if the import is renamed, you can stub using the original name, see [RemotePizza.js](RemotePizza.js) and [RemotePizza.spec.js](RemotePizza.spec.js)
63-
64-
```js
65-
// RemotePizza.js
66-
import { fetchIngredients as defaultFetchIngredients } from './services'
67-
// RemotePizza.spec.js
68-
import * as services from './services'
69-
cy.stub(services, 'fetchIngredients').resolves(...)
70-
```
1+
## Mocking imports
Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1 @@
11
# React Router v6
2-
3-
We are testing the navigation in the [app.jsx](app.jsx) when it is surrounded by a React Router from [react-router-dom](https://github.com/ReactTraining/react-router#readme)
4-
5-
- [spec.cy.jsx](spec.cy.jsx) uses `BrowserRouter`
6-
- [in-memory.cy.jsx](in-memory.cy.jsx) uses `MemoryRouter`
7-
8-
![In memory router spec](images/in-memory.gif)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
This example is taken from repo https://github.com/bruceharris/react-unit-testing-example
1+
## Set timeout example

0 commit comments

Comments
 (0)