Skip to content

Commit af26fbe

Browse files
brian-mannJessicaSachsBarthélémy Ledouxlmiller1990flotwig
authored
feat: component testing (#14479)
Co-authored-by: Jessica Sachs <jess@jessicasachs.io> Co-authored-by: Barthélémy Ledoux <bart@cypress.io> Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com> Co-authored-by: Zach Bloomquist <github@chary.us> Co-authored-by: Dmitriy Kovalenko <dmtr.kovalenko@outlook.com> Co-authored-by: ElevateBart <ledouxb@gmail.com> Co-authored-by: Ben Kucera <14625260+Bkucera@users.noreply.github.com>
1 parent 0abb5ef commit af26fbe

File tree

394 files changed

+49242
-9603
lines changed

Some content is hidden

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

394 files changed

+49242
-9603
lines changed

.eslintrc.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77
"plugin:@cypress/dev/tests"
88
],
99
"rules": {
10+
"@typescript-eslint/no-var-requires": "off",
11+
"@typescript-eslint/no-useless-constructor": "off",
1012
"prefer-spread": "off",
11-
"prefer-rest-params": "off"
13+
"prefer-rest-params": "off",
14+
"no-useless-constructor": "off"
1215
},
1316
"settings": {
1417
"react": {

.vscode/settings.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
{
22
"eslint.alwaysShowStatus": true,
3-
"eslint.validate": ["json"],
3+
"eslint.validate": [
4+
"javascript",
5+
"javascriptreact",
6+
"typescript",
7+
"typescriptreact",
8+
"json"
9+
],
410
"eslint.enable": true,
511
// this project does not use Prettier
612
// thus set all settings to disable accidentally running Prettier

.vscode/tasks.json

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=733558
3+
// for the documentation about the tasks.json format
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"label": "rename yarn workspace packages",
8+
"type": "shell",
9+
"command": "node ./scripts/rename-workspace-packages --file ${file}",
10+
"presentation": {
11+
"echo": true,
12+
"reveal": "silent",
13+
"focus": false,
14+
"panel": "shared",
15+
"showReuseMessage": true,
16+
"clear": false
17+
},
18+
"problemMatcher": []
19+
},
20+
{
21+
"label": "decaffeinate-bulk file",
22+
"type": "shell",
23+
"command": "yarn decaffeinate-bulk convert --file ${file}",
24+
"problemMatcher": []
25+
},
26+
{
27+
"label": "decaffeinate-bulk multiple files",
28+
"type": "shell",
29+
"command": "yarn decaffeinate-bulk convert --file ${file} ${file}",
30+
"problemMatcher": []
31+
},
32+
{
33+
"label": "decaffeinate-bulk dir",
34+
"type": "shell",
35+
"command": "yarn decaffeinate-bulk --dir ${fileDirname} convert",
36+
"problemMatcher": []
37+
}
38+
]
39+
}

.vscode/terminals.json

+33-2
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,43 @@
22
"autorun": false,
33
"terminals": [
44
{
5-
"name": "cypress open",
5+
"name": "yarn",
6+
"focus": true,
7+
"onlySingle": true,
8+
"execute": true,
9+
"cwd": "[cwd]",
10+
"command": "yarn"
11+
},
12+
{
13+
"name": "cypress open (E2E)",
614
"focus": true,
715
"onlySingle": true,
816
"execute": true,
917
"command": "yarn cypress:open"
1018
},
1119
{
12-
"name": "cypress run",
20+
"name": "cypress run (E2E)",
1321
"focus": true,
1422
"onlySingle": true,
1523
"execute": false,
1624
"command": "yarn cypress:run --project ../project"
1725
},
26+
{
27+
"name": "cypress open (CT)",
28+
"focus": true,
29+
"onlySingle": true,
30+
"execute": true,
31+
"cwd": "[cwd]/packages/server-ct",
32+
"command": "yarn cypress:open"
33+
},
34+
{
35+
"name": "packages/server test-e2e",
36+
"focus": true,
37+
"onlySingle": true,
38+
"execute": false,
39+
"cwd": "[cwd]/packages/server",
40+
"command": "yarn test-e2e [fileBasename]"
41+
},
1842
{
1943
"name": "packages/server test-watch",
2044
"focus": true,
@@ -38,6 +62,13 @@
3862
"cwd": "[cwd]/packages/runner",
3963
"command": "yarn watch"
4064
},
65+
{
66+
"name": "packages/runner-ct watch",
67+
"focus": true,
68+
"onlySingle": true,
69+
"cwd": "[cwd]/packages/runner-ct",
70+
"command": "yarn watch"
71+
},
4172
{
4273
"name": "packages/driver cypress open",
4374
"focus": true,

circle.yml

+58-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ macBuildFilters: &macBuildFilters
88
branches:
99
only:
1010
- develop
11+
- v6.0-release
12+
- feat/component-testing
13+
- include-electron-node-version
1114
- sem-next-ver
1215

1316
defaults: &defaults
@@ -35,6 +38,8 @@ testBinaryFirefox: &testBinaryFirefox
3538
branches:
3639
only:
3740
- develop
41+
- v6.0-release
42+
- feat/component-testing
3843
- sem-next-ver
3944
requires:
4045
- build-npm-package
@@ -642,6 +647,20 @@ jobs:
642647
path: /tmp/cypress
643648
- store-npm-logs
644649

650+
server-ct-unit-tests:
651+
<<: *defaults
652+
parallelism: 1
653+
steps:
654+
- attach_workspace:
655+
at: ~/
656+
- check-conditional-ci
657+
- run: yarn test-unit --scope @packages/server-ct
658+
- verify-mocha-results:
659+
expectedResultCount: 1
660+
- store_test_results:
661+
path: /tmp/cypress
662+
- store-npm-logs
663+
645664
server-integration-tests:
646665
<<: *defaults
647666
parallelism: 1
@@ -893,6 +912,16 @@ jobs:
893912
working_directory: npm/webpack-preprocessor/examples/react-app
894913
- store-npm-logs
895914

915+
npm-webpack-dev-server:
916+
<<: *defaults
917+
steps:
918+
- attach_workspace:
919+
at: ~/
920+
- check-conditional-ci
921+
- run:
922+
name: Run tests
923+
command: yarn workspace @cypress/webpack-dev-server test
924+
896925
npm-webpack-batteries-included-preprocessor:
897926
<<: *defaults
898927
steps:
@@ -914,7 +943,8 @@ jobs:
914943
command: yarn workspace @cypress/vue build
915944
- run:
916945
name: Run tests
917-
command: yarn workspace @cypress/vue test
946+
command: yarn test
947+
working_directory: npm/vue
918948
- store-npm-logs
919949

920950
npm-react:
@@ -1711,6 +1741,9 @@ linux-workflow: &linux-workflow
17111741
requires:
17121742
- build
17131743

1744+
- npm-webpack-dev-server:
1745+
requires:
1746+
- build
17141747
- npm-webpack-preprocessor:
17151748
requires:
17161749
- build
@@ -1808,6 +1841,8 @@ linux-workflow: &linux-workflow
18081841
branches:
18091842
only:
18101843
- develop
1844+
- v6.0-release
1845+
- feat/component-testing
18111846
- sem-next-ver
18121847
requires:
18131848
- build
@@ -1826,6 +1861,8 @@ linux-workflow: &linux-workflow
18261861
branches:
18271862
only:
18281863
- develop
1864+
- v6.0-release
1865+
- feat/component-testing
18291866
- sem-next-ver
18301867
requires:
18311868
- build
@@ -1838,6 +1875,8 @@ linux-workflow: &linux-workflow
18381875
branches:
18391876
only:
18401877
- develop
1878+
- v6.0-release
1879+
- feat/component-testing
18411880
- sem-next-ver
18421881
requires:
18431882
- build-npm-package
@@ -1850,6 +1889,8 @@ linux-workflow: &linux-workflow
18501889
branches:
18511890
only:
18521891
- develop
1892+
- v6.0-release
1893+
- feat/component-testing
18531894
- sem-next-ver
18541895
requires:
18551896
- build-binary
@@ -1907,6 +1948,8 @@ linux-workflow: &linux-workflow
19071948
branches:
19081949
only:
19091950
- develop
1951+
- v6.0-release
1952+
- feat/component-testing
19101953
- sem-next-ver
19111954
requires:
19121955
- upload-npm-package
@@ -1917,6 +1960,8 @@ linux-workflow: &linux-workflow
19171960
branches:
19181961
only:
19191962
- develop
1963+
- v6.0-release
1964+
- feat/component-testing
19201965
- sem-next-ver
19211966
requires:
19221967
- upload-npm-package
@@ -1926,6 +1971,8 @@ linux-workflow: &linux-workflow
19261971
branches:
19271972
only:
19281973
- develop
1974+
- v6.0-release
1975+
- feat/component-testing
19291976
- sem-next-ver
19301977
requires:
19311978
- build-npm-package
@@ -1936,6 +1983,8 @@ linux-workflow: &linux-workflow
19361983
branches:
19371984
only:
19381985
- develop
1986+
- v6.0-release
1987+
- feat/component-testing
19391988
- sem-next-ver
19401989
requires:
19411990
- build-npm-package
@@ -1962,6 +2011,8 @@ linux-workflow: &linux-workflow
19622011
branches:
19632012
only:
19642013
- develop
2014+
- v6.0-release
2015+
- feat/component-testing
19652016
- sem-next-ver
19662017
requires:
19672018
- build-npm-package
@@ -2056,6 +2107,8 @@ mac-workflow: &mac-workflow
20562107
branches:
20572108
only:
20582109
- develop
2110+
- v6.0-release
2111+
- feat/component-testing
20592112
- sem-next-ver
20602113
requires:
20612114
- Mac NPM package
@@ -2069,6 +2122,8 @@ mac-workflow: &mac-workflow
20692122
branches:
20702123
only:
20712124
- develop
2125+
- v6.0-release
2126+
- feat/component-testing
20722127
- sem-next-ver
20732128
requires:
20742129
- Mac NPM package upload
@@ -2082,6 +2137,8 @@ mac-workflow: &mac-workflow
20822137
branches:
20832138
only:
20842139
- develop
2140+
- v6.0-release
2141+
- feat/component-testing
20852142
- sem-next-ver
20862143
requires:
20872144
- Mac NPM package upload

cli/__snapshots__/cli_spec.js

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ exports['shows help for open --foo 1'] = `
3535
-P, --project <project-path> path to the project
3636
--dev runs cypress in development and bypasses
3737
binary check
38+
-ct, --component-testing Cypress Component Testing mode (alpha)
3839
-h, --help display help for command
3940
-------
4041
stderr:

cli/lib/cli.js

+2
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ module.exports = {
401401
.option('--global', text('global'))
402402
.option('-p, --port <port>', text('port'))
403403
.option('-P, --project <project-path>', text('project'))
404+
.option('--run-project <project-path>', 'like `project`, but forces Cypress into runmode')
404405
.option('--dev', text('dev'), coerceFalse)
405406
.action((opts) => {
406407
debug('opening Cypress')
@@ -422,6 +423,7 @@ module.exports = {
422423
.option('-p, --port <port>', text('port'))
423424
.option('-P, --project <project-path>', text('project'))
424425
.option('--dev', text('dev'), coerceFalse)
426+
.option('-ct, --component-testing', 'Cypress Component Testing mode (alpha)')
425427
.action((opts) => {
426428
debug('opening Cypress')
427429
require('./exec/open')

cli/lib/exec/open.js

+4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ module.exports = {
3737

3838
if (isComponentTesting) {
3939
args.push('--componentTesting')
40+
41+
if (options.runProject) {
42+
args.push('--run-project', options.runProject)
43+
}
4044
}
4145

4246
debug('opening from options %j', options)

cli/lib/exec/xvfb.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ const os = require('os')
22
const Promise = require('bluebird')
33
const Xvfb = require('@cypress/xvfb')
44
const { stripIndent } = require('common-tags')
5-
const debug = require('debug')('cypress:cli')
6-
const debugXvfb = require('debug')('cypress:xvfb')
5+
const Debug = require('debug')
76
const { throwFormErrorText, errors } = require('../errors')
87
const util = require('../util')
98

9+
const debug = Debug('cypress:cli')
10+
const debugXvfb = Debug('cypress:xvfb')
11+
12+
debug.Debug = debugXvfb.Debug = Debug
13+
1014
const xvfbOptions = {
1115
timeout: 30000, // milliseconds
1216
// need to explicitly define screen otherwise electron will crash

cli/lib/util.js

+1
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ const parseOpts = (opts) => {
220220
'reporter',
221221
'reporterOptions',
222222
'record',
223+
'runProject',
223224
'spec',
224225
'tag')
225226

cli/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"@cypress/listr-verbose-renderer": "^0.4.1",
2424
"@cypress/request": "^2.88.5",
2525
"@cypress/xvfb": "^1.2.4",
26+
"@types/node": "12.12.50",
2627
"@types/sinonjs__fake-timers": "^6.0.1",
2728
"@types/sizzle": "^2.3.2",
2829
"arch": "^2.1.2",
@@ -35,7 +36,7 @@
3536
"commander": "^5.1.0",
3637
"common-tags": "^1.8.0",
3738
"dayjs": "^1.9.3",
38-
"debug": "^4.1.1",
39+
"debug": "4.3.2",
3940
"eventemitter2": "^6.4.2",
4041
"execa": "^4.0.2",
4142
"executable": "^4.1.1",

0 commit comments

Comments
 (0)