Skip to content

Commit 196e8f6

Browse files
Blue Fchrisbreiding
Blue F
andauthored
feat: Deprecate run-ct / open-ct, and update all examples to use --ct instead (#18422)
Co-authored-by: Chris Breiding <chrisbreiding@users.noreply.github.com>
1 parent 0d098ae commit 196e8f6

File tree

52 files changed

+304
-150
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+304
-150
lines changed

cli/__snapshots__/cli_spec.js

+17-7
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ exports['shows help for open --foo 1'] = `
1818
Options:
1919
-b, --browser <browser-path> path to a custom browser to be added to the
2020
list of available browsers in Cypress
21+
--component runs component tests
2122
-c, --config <config> sets configuration values. separate multiple
2223
values with a comma. overrides any value in
2324
cypress.json.
24-
--ct, --component runs component tests
2525
-C, --config-file <config-file> path to JSON file where configuration values
2626
are set. defaults to "cypress.json". pass
2727
"false" to disable.
@@ -66,7 +66,7 @@ exports['shows help for run --foo 1'] = `
6666
Options:
6767
-b, --browser <browser-name-or-path> runs Cypress in the browser with the given name. if a filesystem path is supplied, Cypress will attempt to use the browser at that path.
6868
--ci-build-id <id> the unique identifier for a run on your CI provider. typically a "BUILD_ID" env var. this value is automatically detected for most CI providers
69-
--ct, --component runs component tests
69+
--component runs component tests
7070
-c, --config <config> sets configuration values. separate multiple values with a comma. overrides any value in cypress.json.
7171
-C, --config-file <config-file> path to JSON file where configuration values are set. defaults to "cypress.json". pass "false" to disable.
7272
--e2e runs end to end tests
@@ -218,7 +218,9 @@ exports['cli help command shows help 1'] = `
218218
open [options] Opens Cypress in the interactive GUI.
219219
run [options] Runs Cypress tests from the CLI without the GUI
220220
open-ct [options] Opens Cypress component testing interactive mode.
221-
run-ct [options] Runs all Cypress Component Testing suites
221+
Deprecated: use "open --component"
222+
run-ct [options] Runs all Cypress component testing suites. Deprecated:
223+
use "run --component"
222224
install [options] Installs the Cypress executable matching this package's
223225
version
224226
verify [options] Verifies that Cypress is installed correctly and
@@ -256,7 +258,9 @@ exports['cli help command shows help for -h 1'] = `
256258
open [options] Opens Cypress in the interactive GUI.
257259
run [options] Runs Cypress tests from the CLI without the GUI
258260
open-ct [options] Opens Cypress component testing interactive mode.
259-
run-ct [options] Runs all Cypress Component Testing suites
261+
Deprecated: use "open --component"
262+
run-ct [options] Runs all Cypress component testing suites. Deprecated:
263+
use "run --component"
260264
install [options] Installs the Cypress executable matching this package's
261265
version
262266
verify [options] Verifies that Cypress is installed correctly and
@@ -294,7 +298,9 @@ exports['cli help command shows help for --help 1'] = `
294298
open [options] Opens Cypress in the interactive GUI.
295299
run [options] Runs Cypress tests from the CLI without the GUI
296300
open-ct [options] Opens Cypress component testing interactive mode.
297-
run-ct [options] Runs all Cypress Component Testing suites
301+
Deprecated: use "open --component"
302+
run-ct [options] Runs all Cypress component testing suites. Deprecated:
303+
use "run --component"
298304
install [options] Installs the Cypress executable matching this package's
299305
version
300306
verify [options] Verifies that Cypress is installed correctly and
@@ -333,7 +339,9 @@ exports['cli unknown command shows usage and exits 1'] = `
333339
open [options] Opens Cypress in the interactive GUI.
334340
run [options] Runs Cypress tests from the CLI without the GUI
335341
open-ct [options] Opens Cypress component testing interactive mode.
336-
run-ct [options] Runs all Cypress Component Testing suites
342+
Deprecated: use "open --component"
343+
run-ct [options] Runs all Cypress component testing suites. Deprecated:
344+
use "run --component"
337345
install [options] Installs the Cypress executable matching this package's
338346
version
339347
verify [options] Verifies that Cypress is installed correctly and
@@ -458,7 +466,9 @@ exports['cli CYPRESS_INTERNAL_ENV allows and warns when staging environment 1']
458466
open [options] Opens Cypress in the interactive GUI.
459467
run [options] Runs Cypress tests from the CLI without the GUI
460468
open-ct [options] Opens Cypress component testing interactive mode.
461-
run-ct [options] Runs all Cypress Component Testing suites
469+
Deprecated: use "open --component"
470+
run-ct [options] Runs all Cypress component testing suites. Deprecated:
471+
use "run --component"
462472
install [options] Installs the Cypress executable matching this package's
463473
version
464474
verify [options] Verifies that Cypress is installed correctly and

cli/lib/cli.js

+25-4
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ const addCypressRunCommand = (program) => {
250250
.description('Runs Cypress tests from the CLI without the GUI')
251251
.option('-b, --browser <browser-name-or-path>', text('browserRunMode'))
252252
.option('--ci-build-id <id>', text('ciBuildId'))
253-
.option('--ct, --component', text('component'))
253+
.option('--component', text('component'))
254254
.option('-c, --config <config>', text('config'))
255255
.option('-C, --config-file <config-file>', text('configFile'))
256256
.option('--e2e', text('e2e'))
@@ -389,8 +389,8 @@ module.exports = {
389389
.usage('[options]')
390390
.description('Opens Cypress in the interactive GUI.')
391391
.option('-b, --browser <browser-path>', text('browserOpenMode'))
392+
.option('--component', text('component'))
392393
.option('-c, --config <config>', text('config'))
393-
.option('--ct, --component', text('component'))
394394
.option('-C, --config-file <config-file>', text('configFile'))
395395
.option('-d, --detached [bool]', text('detached'), coerceFalse)
396396
.option('--e2e', text('e2e'))
@@ -419,7 +419,7 @@ module.exports = {
419419
program
420420
.command('open-ct')
421421
.usage('[options]')
422-
.description('Opens Cypress component testing interactive mode.')
422+
.description('Opens Cypress component testing interactive mode. Deprecated: use "open --component"')
423423
.option('-b, --browser <browser-path>', text('browserOpenMode'))
424424
.option('-c, --config <config>', text('config'))
425425
.option('-C, --config-file <config-file>', text('configFile'))
@@ -431,6 +431,17 @@ module.exports = {
431431
.option('--dev', text('dev'), coerceFalse)
432432
.action((opts) => {
433433
debug('opening Cypress')
434+
435+
const msg = `
436+
${logSymbols.warning} Warning: open-ct is deprecated and will be removed in a future release.
437+
438+
Use \`cypress open --component\` instead.
439+
`
440+
441+
logger.warn()
442+
logger.warn(stripIndent(msg))
443+
logger.warn()
444+
434445
require('./exec/open')
435446
.start({ ...util.parseOpts(opts), testingType: 'component' })
436447
.catch(util.logErrorExit1)
@@ -439,7 +450,7 @@ module.exports = {
439450
program
440451
.command('run-ct')
441452
.usage('[options]')
442-
.description('Runs all Cypress Component Testing suites')
453+
.description('Runs all Cypress component testing suites. Deprecated: use "run --component"')
443454
.option('-b, --browser <browser-name-or-path>', text('browserRunMode'))
444455
.option('--ci-build-id <id>', text('ciBuildId'))
445456
.option('-c, --config <config>', text('config'))
@@ -462,6 +473,16 @@ module.exports = {
462473
.option('--dev', text('dev'), coerceFalse)
463474
.action((opts) => {
464475
debug('running Cypress run-ct')
476+
477+
const msg = `
478+
${logSymbols.warning} Warning: run-ct is deprecated and will be removed in a future release.
479+
Use \`cypress run --component\` instead.
480+
`
481+
482+
logger.warn()
483+
logger.warn(stripIndent(msg))
484+
logger.warn()
485+
465486
require('./exec/run')
466487
.start({ ...util.parseOpts(opts), testingType: 'component' })
467488
.then(util.exit)

cli/test/lib/cli_spec.js

+12
Original file line numberDiff line numberDiff line change
@@ -629,12 +629,24 @@ describe('cli', () => {
629629
})
630630

631631
it('spawns server with correct args for component-testing', () => {
632+
this.exec('open --component --dev')
633+
expect(spawn.start.firstCall.args[0]).to.include('--testing-type')
634+
expect(spawn.start.firstCall.args[0]).to.include('component')
635+
})
636+
637+
it('spawns server with correct args for depricated component-testing command', () => {
632638
this.exec('open-ct --dev')
633639
expect(spawn.start.firstCall.args[0]).to.include('--testing-type')
634640
expect(spawn.start.firstCall.args[0]).to.include('component')
635641
})
636642

637643
it('runs server with correct args for component-testing', () => {
644+
this.exec('run --component --dev')
645+
expect(spawn.start.firstCall.args[0]).to.include('--testing-type')
646+
expect(spawn.start.firstCall.args[0]).to.include('component')
647+
})
648+
649+
it('runs server with correct args for depricated component-testing command', () => {
638650
this.exec('run-ct --dev')
639651
expect(spawn.start.firstCall.args[0]).to.include('--testing-type')
640652
expect(spawn.start.firstCall.args[0]).to.include('component')

cli/test/lib/exec/run_spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ describe('exec run', function () {
197197
})
198198
})
199199

200-
it('spawns with --testing-type component when given --ct', function () {
201-
return run.start({ ct: true })
200+
it('spawns with --testing-type component when given --component', function () {
201+
return run.start({ component: true })
202202
.then(() => {
203203
expect(spawn.start).to.be.calledWith(['--run-project', process.cwd(), '--testing-type', 'component'])
204204
})

cli/types/cypress.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ declare namespace Cypress {
143143

144144
/**
145145
* Spec type for the given test. "integration" is the default, but
146-
* tests run using `open-ct` will be "component"
146+
* tests run using `open --component` will be "component"
147147
*
148148
* @see https://on.cypress.io/experiments
149149
*/

npm/angular/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"scripts": {
88
"build": "tsc --project tsconfig.lib.json",
99
"watch": "tsc --project tsconfig.lib.json -w",
10-
"cy:open": "node ../../scripts/cypress.js open-ct",
11-
"cy:run": "node ../../scripts/cypress.js run-ct",
10+
"cy:open": "node ../../scripts/cypress.js open --component",
11+
"cy:run": "node ../../scripts/cypress.js run --component",
1212
"ng": "ng",
1313
"app-start": "ng serve",
1414
"app-build": "ng build",

npm/create-cypress-tests/src/main.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ function printCypressCommandsHelper (options: { shouldSetupComponentTesting: boo
6464
printCommand('cypress run', 'Runs tests in headless mode.')
6565

6666
if (options.shouldSetupComponentTesting) {
67-
printCommand('cypress open-ct', 'Opens cypress component-testing web app.')
68-
printCommand('cypress run-ct', 'Runs component testing in headless mode.')
67+
printCommand('cypress open --component', 'Opens Cypress component testing interactive mode.')
68+
printCommand('cypress run-ct', 'Runs all Cypress component testing suites.')
6969
}
7070
}
7171

npm/design-system/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
"build-prod": "yarn build",
99
"build-storybook": "build-storybook",
1010
"build-style-types": "tsm \"src/css/derived/*.scss\" --nameFormat none --exportType default",
11-
"cy:open": "node ../../scripts/cypress.js open-ct --project ${PWD}",
11+
"cy:open": "node ../../scripts/cypress.js open --component --project ${PWD}",
1212
"cy:open:debug": "node --inspect-brk ../../scripts/start.js --component-testing --project ${PWD}",
13-
"cy:run": "node ../../scripts/cypress.js run-ct --project ${PWD}",
13+
"cy:run": "node ../../scripts/cypress.js run --component --project ${PWD}",
1414
"cy:run:debug": "node --inspect-brk ../../scripts/start.js --component-testing --run-project ${PWD}",
1515
"storybook": "start-storybook -p 6006",
1616
"test": "yarn cy:run",

npm/react/examples/a11y/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"description": "Testing component accessibility",
44
"private": true,
55
"scripts": {
6-
"cy:open": "node ../../../../scripts/cypress open-ct",
7-
"test": "node ../../../../scripts/cypress run-ct"
6+
"cy:open": "node ../../../../scripts/cypress open --component",
7+
"test": "node ../../../../scripts/cypress run --component"
88
},
99
"devDependencies": {
1010
"@cypress/react": "file:../../dist",

npm/react/examples/craco/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {
6-
"cy:open": "node ../../../../scripts/cypress open-ct",
7-
"test": "node ../../../../scripts/cypress run-ct",
6+
"cy:open": "node ../../../../scripts/cypress open --component",
7+
"test": "node ../../../../scripts/cypress run --component",
88
"start": "craco start",
99
"build": "craco build"
1010
},

npm/react/examples/find-webpack/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Most tests will start with `mount` from `@cypress/react`. This is similar to `re
7171
Open the component testing runner with:
7272

7373
```sh
74-
yarn cypress open-ct
74+
yarn cypress open --component
7575
```
7676

7777
And select the spec to run.
@@ -80,7 +80,7 @@ And select the spec to run.
8080

8181
Try making a change - the tests will re-run instantly. You not only immediately know if the test passed or failed, but be able to visually inspect and debug any changes.
8282

83-
You can run all the specs with `yarn cypress run-ct`. This is useful for executing all the specs in a CI environment, or one last check before you commit and push your code!
83+
You can run all the specs with `yarn cypress run --component`. This is useful for executing all the specs in a CI environment, or one last check before you commit and push your code!
8484

8585
## Discussion
8686

@@ -90,13 +90,13 @@ Cypress Component Testing is an alternative to a jsdom based testing environment
9090
- Visual. You can see exactly what is rendered. No more scrolling through a cryptic terminal log to figure out what is rendered or to debug - just open the devtools and browse the DOM.
9191
- Powered by Cypress - the most popular and reliable E2E testing tool out there.
9292

93-
It also doubles as a *design environment*. You can see the component as you develop it, and hot reload give you a near instance feedback loop. It can potentially take the place of not only your Jest based test infrastructure, but your Storybook based design infrastructure as well.
93+
It also doubles as a *design environment*. You can see the component as you develop it, and hot reload give you a near instance feedback loop. It can potentially take the place of not only your Jest based test infrastructure, but your Storybook based design infrastructure as well.
9494

9595
Cypress Component Testing is still in alpha but the product is quickly evolving and promises to change the landscape of Component Testing.
9696

9797
## Conclusion
9898

99-
Cypress Component Testing brings everything that is great about Cypress to Component Testing. Since the underlying adapters are built on libraries like Webpack, you don't need to throw away your entire test suite - incremental migration is more than possible.
99+
Cypress Component Testing brings everything that is great about Cypress to Component Testing. Since the underlying adapters are built on libraries like Webpack, you don't need to throw away your entire test suite - incremental migration is more than possible.
100100

101101
The visual aspect united testing and design in a single tool. My days of grepping a messy console output to figure out what the user will see are over - I can see exactly what the component will look like as my tests run.
102102

npm/react/examples/find-webpack/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"version": "1.0.0",
44
"private": true,
55
"scripts": {
6-
"cy:open": "node ../../../../scripts/cypress open-ct",
7-
"test": "node ../../../../scripts/cypress run-ct"
6+
"cy:open": "node ../../../../scripts/cypress open --component",
7+
"test": "node ../../../../scripts/cypress run --component"
88
},
99
"dependencies": {
1010
"@types/react": "^17.0.0",

npm/react/examples/nextjs-webpack-5/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {
6-
"cy:open": "node ../../../../scripts/cypress open-ct",
6+
"cy:open": "node ../../../../scripts/cypress open --component",
77
"dev": "next",
88
"start": "next start",
9-
"test": "node ../../../../scripts/cypress run-ct"
9+
"test": "node ../../../../scripts/cypress run --component"
1010
},
1111
"dependencies": {
1212
"next": "10.1.3",

npm/react/examples/nextjs/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
"build": "next build",
77
"build:static": "next build && next out",
88
"check-coverage": "check-coverage components/Search.jsx && check-coverage pages/index.js && check-coverage pages/router.js",
9-
"cy:open": "node ../../../../scripts/cypress open-ct",
9+
"cy:open": "node ../../../../scripts/cypress open --component",
1010
"dev": "next",
1111
"only-covered": "only-covered components/Search.jsx pages/index.js pages/router.js",
1212
"start": "next start",
13-
"test": "node ../../../../scripts/cypress run-ct"
13+
"test": "node ../../../../scripts/cypress run --component"
1414
},
1515
"devDependencies": {
1616
"@cypress/react": "file:../../dist",

npm/react/examples/react-scripts-folder/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"private": true,
66
"scripts": {
77
"check-coverage": "check-coverage src/App.js src/calc.js src/Child.js",
8-
"cy:open": "node ../../../../scripts/cypress open-ct",
8+
"cy:open": "node ../../../../scripts/cypress open --component",
99
"only-covered": "only-covered src/App.js src/calc.js src/Child.js",
10-
"test": "node ../../../../scripts/cypress run-ct"
10+
"test": "node ../../../../scripts/cypress run --component"
1111
},
1212
"devDependencies": {
1313
"@cypress/react": "file:../../dist",

npm/react/examples/react-scripts-typescript/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"private": true,
33
"scripts": {
4-
"cy:open": "node ../../../../scripts/cypress open-ct",
4+
"cy:open": "node ../../../../scripts/cypress open --component",
55
"start": "react-scripts start",
6-
"test": "node ../../../../scripts/cypress run-ct"
6+
"test": "node ../../../../scripts/cypress run --component"
77
},
88
"dependencies": {
99
"react": "^17.0.1",

npm/react/examples/react-scripts/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"private": true,
55
"scripts": {
66
"check-coverage": "check-coverage src/App.js src/calc.js src/Child.js src/services.js src/RemotePizza.js cypress/fixtures/add.js",
7-
"cy:open": "node ../../../../scripts/cypress open-ct",
7+
"cy:open": "node ../../../../scripts/cypress open --component",
88
"only-covered": "only-covered src/App.js src/calc.js src/Child.js src/services.js src/RemotePizza.js cypress/fixtures/add.js",
99
"start": "react-scripts start",
10-
"test": "node ../../../../scripts/cypress run-ct"
10+
"test": "node ../../../../scripts/cypress run --component"
1111
},
1212
"devDependencies": {
1313
"@cypress/react": "file:../../dist",

npm/react/examples/sass-and-ts/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"private": true,
55
"scripts": {
66
"check-coverage": "check-coverage src/App.tsx",
7-
"cy:open": "node ../../../../scripts/cypress open-ct",
7+
"cy:open": "node ../../../../scripts/cypress open --component",
88
"only-covered": "only-covered src/App.tsx",
9-
"test": "node ../../../../scripts/cypress run-ct"
9+
"test": "node ../../../../scripts/cypress run --component"
1010
},
1111
"dependencies": {
1212
"sass-loader": "10.0.2"

npm/react/examples/snapshots/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"private": true,
55
"scripts": {
66
"check-coverage": "check-coverage src/App.js",
7-
"cy:open": "node ../../../../scripts/cypress open-ct",
7+
"cy:open": "node ../../../../scripts/cypress open --component",
88
"only-covered": "only-covered src/App.js",
9-
"test": "node ../../../../scripts/cypress run-ct"
9+
"test": "node ../../../../scripts/cypress run --component"
1010
},
1111
"devDependencies": {
1212
"@cypress/react": "file:../../dist",

npm/react/examples/tailwind/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"scripts": {
66
"build:css": "tailwindcss build src/styles/tailwind.css -o src/styles/main.generated.css",
77
"precy:open": "npm run build:css",
8-
"cy:open": "node ../../../../scripts/cypress open-ct",
8+
"cy:open": "node ../../../../scripts/cypress open --component",
99
"pretest": "npm run build:css",
10-
"test": "node ../../../../scripts/cypress run-ct"
10+
"test": "node ../../../../scripts/cypress run --component"
1111
},
1212
"devDependencies": {
1313
"@cypress/react": "file:../../dist",

0 commit comments

Comments
 (0)