Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create config package for config validation #18589

Merged
merged 75 commits into from
Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from 65 commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
5443611
(feat): create config package for config validation in server & driver
emilyrohrbough Oct 20, 2021
045fde3
cleanup
emilyrohrbough Oct 20, 2021
14632cc
.
emilyrohrbough Oct 20, 2021
b92b3b1
add tests to config
emilyrohrbough Oct 21, 2021
dcfaa5b
clean up
emilyrohrbough Oct 21, 2021
a8e405e
missed update
emilyrohrbough Oct 21, 2021
c7440d1
Merge branch 'develop' into add-config-validation
emilyrohrbough Oct 21, 2021
acd4b77
fix obj overrding issue
emilyrohrbough Oct 21, 2021
8fb03ab
tests
emilyrohrbough Oct 21, 2021
f149559
dependencies
emilyrohrbough Oct 21, 2021
e723b03
update missed import
emilyrohrbough Oct 21, 2021
d843170
fixes one of the two test issues
emilyrohrbough Oct 22, 2021
a38fb6a
Merge branch 'develop' into add-config-validation
emilyrohrbough Oct 22, 2021
3fdd15c
dang. thought this had already been changed.
emilyrohrbough Oct 22, 2021
4bfcfae
clean up
emilyrohrbough Oct 22, 2021
5e52676
clean pu
emilyrohrbough Oct 22, 2021
d0a9967
Merge branch 'develop' into add-config-validation
emilyrohrbough Oct 22, 2021
82b1119
...
emilyrohrbough Oct 25, 2021
ba6d586
Merge branch 'develop' into add-config-validation
emilyrohrbough Oct 25, 2021
00fed44
Merge branch 'develop' into add-config-validation
emilyrohrbough Oct 25, 2021
91dfd3f
Merge branch 'develop' into add-config-validation
emilyrohrbough Oct 25, 2021
6826069
improve import variable name
emilyrohrbough Oct 26, 2021
f449b9d
clean up pkg.json
emilyrohrbough Oct 26, 2021
c64a652
add the codeframe / UI error logic for test overrides
emilyrohrbough Oct 28, 2021
eae59f8
reset this bit.
emilyrohrbough Oct 28, 2021
63d18cf
fix codeframe for mocha suites vs tests & nested blocks
emilyrohrbough Oct 29, 2021
402a393
inlint test config overrides with correct stack trace
emilyrohrbough Nov 1, 2021
f279e36
typo
emilyrohrbough Nov 1, 2021
904c22b
Merge branch 'develop' into add-config-validation
emilyrohrbough Nov 1, 2021
1af43ac
fix global config state
emilyrohrbough Nov 1, 2021
b4ce459
Merge branch 'develop' into add-config-validation
emilyrohrbough Nov 1, 2021
c3ec924
Merge branch 'develop' into add-config-validation
emilyrohrbough Nov 1, 2021
762470c
reset config as expected
emilyrohrbough Nov 1, 2021
3486ab1
fix compile/types test
emilyrohrbough Nov 2, 2021
eafacca
re-add common-tags used in tests
emilyrohrbough Nov 2, 2021
a12e5d2
dont lint compiled code.
emilyrohrbough Nov 2, 2021
ffc43c5
.
emilyrohrbough Nov 2, 2021
9e37c63
dep not dev dep
emilyrohrbough Nov 2, 2021
cd13f0e
Merge branch 'develop' into add-config-validation
emilyrohrbough Nov 2, 2021
2b517be
have not been able to reproduce test failures locally
emilyrohrbough Nov 2, 2021
953dacd
fix the typsescript compiling
emilyrohrbough Nov 3, 2021
e05ceb3
clean up tsc
emilyrohrbough Nov 3, 2021
d4d4354
Merge branch 'develop' into add-config-validation
emilyrohrbough Nov 3, 2021
39dadca
fix slow test threshold.
emilyrohrbough Nov 3, 2021
766502c
Merge branch 'add-config-validation' of https://github.com/cypress-io…
emilyrohrbough Nov 3, 2021
4a34493
fix
emilyrohrbough Nov 3, 2021
f0676e2
clean up
emilyrohrbough Nov 3, 2021
2e27112
aAH. fix broken system tests
emilyrohrbough Nov 4, 2021
ab89639
fix types & update snapshots
emilyrohrbough Nov 4, 2021
530e19d
Update navigation_spec.js
emilyrohrbough Nov 4, 2021
b351eda
PR comments
emilyrohrbough Nov 4, 2021
35fc415
intented for this to release with 9.0.0
emilyrohrbough Nov 4, 2021
8bdfd57
remove @packages/config build script & move all from src to lib
emilyrohrbough Nov 5, 2021
619ee85
update gitignore for compile .js files in lib
emilyrohrbough Nov 5, 2021
a28cd4f
Merge branch 'develop' into add-config-validation
emilyrohrbough Nov 5, 2021
c0a47ca
handle before/beforeEach hooks
emilyrohrbough Nov 8, 2021
eaead0d
fix event emitting & retries
emilyrohrbough Nov 8, 2021
4905d32
Merge branch 'add-config-validation' of https://github.com/cypress-io…
emilyrohrbough Nov 8, 2021
5cb2f5e
typo
emilyrohrbough Nov 8, 2021
f582b3c
fix import
emilyrohrbough Nov 8, 2021
f0d538a
revert local change that was checked in
emilyrohrbough Nov 8, 2021
b804ea3
revert change that would require Product Review & alters the behavior…
emilyrohrbough Nov 8, 2021
1052df3
fix driver errors that highlighted the beforeeach hook issue
emilyrohrbough Nov 8, 2021
537e583
update snapshots
emilyrohrbough Nov 8, 2021
84f53d1
fix runner:test:before:run:asyn event exec
emilyrohrbough Nov 8, 2021
d97e70f
Merge branch '9.0-release' into add-config-validation
emilyrohrbough Nov 8, 2021
2e62654
missed merge conflict
emilyrohrbough Nov 8, 2021
5bad91c
fix unit tests
emilyrohrbough Nov 8, 2021
b6b3e7c
system tests
emilyrohrbough Nov 8, 2021
db58a8c
.
emilyrohrbough Nov 8, 2021
5ddf2dd
update snapshot
emilyrohrbough Nov 8, 2021
f554233
snapshot
emilyrohrbough Nov 8, 2021
e4c351d
snapshots
emilyrohrbough Nov 8, 2021
7341dec
ahh firefox throws window.Error differently
emilyrohrbough Nov 9, 2021
1414fd7
missed from merging in matts node changes
emilyrohrbough Nov 9, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ system-tests/projects/e2e/cypress/integration/typescript_syntax_error_spec.ts

# cli/types is linted by tslint/dtslint
cli/types

# packages/example is not linted (think about changing this)
packages/example

Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ cypress.zip
Cached Theme.pak
Cached Theme Material Design.pak

# from config, compiled .js files
packages/config/lib/*.js

# from data-context, compiled .js files
packages/data-context/src/**/*.js

# from desktop-gui
packages/desktop-gui/cypress/videos
packages/desktop-gui/src/jsconfig.json


# from driver
packages/driver/cypress/videos
packages/driver/cypress/screenshots
Expand Down
4 changes: 3 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
// To see these extensions in VS Code:
// 1. Open the Command Palette (Ctrl+Shift+P)
// 1. Open the Command Palette:
// - Non-Mac Users: (Ctrl+Shift+P)
// - Mac Users: (Cmd+Shift+P)
// 2. Select "Extensions: Show Recommended Extensions"

// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
Expand Down
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ jobs:
desktop-gui-component-tests,
cli-visual-tests,
runner-integration-tests-chrome,
runner-ct-integration-tests-chrome
runner-ct-integration-tests-chrome,
flotwig marked this conversation as resolved.
Show resolved Hide resolved
reporter-integration-tests,
- run: yarn percy build:finalize

Expand Down
1 change: 1 addition & 0 deletions cli/schema/cypress.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"properties": {
"baseUrl": {
"type": "string",
"default": null,
"description": "Url used as prefix for cy.visit() or cy.request() command’s url. Example http://localhost:3030 or https://test.my-domain.com"
},
"env": {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"bump": "node ./scripts/binary.js bump",
"check-node-version": "node scripts/check-node-version.js",
"check-terminal": "node scripts/check-terminal.js",
"clean": "lerna run clean --parallel",
"clean": "lerna run clean --parallel --no-bail",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(can't comment on the right line, but:) I think the "test" command also needs to be updated so the config package tests run in CI:

"test": "yarn lerna exec yarn test --scope cypress --scope \"'@packages/{config,electron,extension,https-proxy,launcher,net-stubbing,network,proxy,rewriter,runner,runner-shared,socket}'\"",

Right now I'm not sure they run in CI. I don't see them in unit-tests: https://app.circleci.com/pipelines/github/cypress-io/cypress/26077/workflows/af61706e-6d22-4391-bcf9-4c07335b7ac6/jobs/981791

(why do we have a test-unit and a test command? no good reason)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call: b351eda (#18589)

"clean-deps": "find . -depth -name node_modules -type d -exec rm -rf {} \\;",
"clean-untracked-files": "git clean -d -f",
"precypress:open": "yarn ensure-deps",
Expand Down Expand Up @@ -46,7 +46,7 @@
"stop-only": "npx stop-only --skip .cy,.publish,.projects,node_modules,dist,dist-test,fixtures,lib,bower_components,src,__snapshots__ --exclude e2e.ts,cypress-tests.ts",
"stop-only-all": "yarn stop-only --folder packages",
"pretest": "yarn ensure-deps",
"test": "yarn lerna exec yarn test --scope cypress --scope \"'@packages/{electron,extension,https-proxy,launcher,net-stubbing,network,proxy,rewriter,runner,runner-shared,socket}'\"",
"test": "yarn lerna exec yarn test --scope cypress --scope \"'@packages/{config,electron,extension,https-proxy,launcher,net-stubbing,network,proxy,rewriter,runner,runner-shared,socket}'\"",
"test-debug": "lerna exec yarn test-debug --ignore \"'@packages/{desktop-gui,driver,root,static,web-config}'\"",
"pretest-e2e": "yarn ensure-deps",
"test-integration": "lerna exec yarn test-integration --ignore \"'@packages/{desktop-gui,driver,root,static,web-config}'\"",
Expand Down
6 changes: 6 additions & 0 deletions packages/config/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": [
"../../.eslintrc.json"
],
"parser": "@typescript-eslint/parser"
}
11 changes: 11 additions & 0 deletions packages/config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Config

The `config` package contains the configuration types and validation used in both the `server` and the `driver` for setting the Cypress configuration values.

## Testing

### Unit Tests

```bash
yarn workspace @packages/config test-unit
```
145 changes: 145 additions & 0 deletions packages/config/__snapshots__/index_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
exports['src/index .getBreakingKeys returns list of breaking config keys 1'] = [
"blacklistHosts",
"experimentalComponentTesting",
"experimentalGetCookiesSameSite",
"experimentalNetworkStubbing",
"experimentalRunEvents",
"experimentalShadowDomSupport",
"firefoxGcInterval"
]

exports['src/index .getDefaultValues returns list of public config keys 1'] = {
"animationDistanceThreshold": 5,
"baseUrl": null,
"blockHosts": null,
"chromeWebSecurity": true,
"clientCertificates": [],
"component": {},
"componentFolder": "cypress/component",
"defaultCommandTimeout": 4000,
"downloadsFolder": "cypress/downloads",
"e2e": {},
"env": {},
"execTimeout": 60000,
"experimentalFetchPolyfill": false,
"experimentalInteractiveRunEvents": false,
"experimentalSessionSupport": false,
"experimentalSourceRewriting": false,
"experimentalStudio": false,
"fileServerFolder": "",
"fixturesFolder": "cypress/fixtures",
"ignoreTestFiles": "*.hot-update.js",
"includeShadowDom": false,
"integrationFolder": "cypress/integration",
"modifyObstructiveCode": true,
"nodeVersion": "default",
"numTestsKeptInMemory": 50,
"pageLoadTimeout": 60000,
"pluginsFile": "cypress/plugins",
"port": null,
"projectId": null,
"redirectionLimit": 20,
"reporter": "spec",
"reporterOptions": null,
"requestTimeout": 5000,
"resolvedNodePath": null,
"resolvedNodeVersion": null,
"responseTimeout": 30000,
"retries": {
"runMode": 0,
"openMode": 0
},
"screenshotOnRunFailure": true,
"screenshotsFolder": "cypress/screenshots",
"slowTestThreshold": 10000,
"scrollBehavior": "top",
"supportFile": "cypress/support",
"supportFolder": false,
"taskTimeout": 60000,
"testFiles": "**/*.*",
"trashAssetsBeforeRuns": true,
"userAgent": null,
"video": true,
"videoCompression": 32,
"videosFolder": "cypress/videos",
"videoUploadOnPasses": true,
"viewportHeight": 660,
"viewportWidth": 1000,
"waitForAnimations": true,
"watchForFileChanges": true,
"autoOpen": false,
"browsers": [],
"clientRoute": "/__/",
"configFile": "cypress.json",
"devServerPublicPathRoute": "/__cypress/src",
"hosts": null,
"isTextTerminal": false,
"morgan": true,
"namespace": "__cypress",
"reporterRoute": "/__cypress/reporter",
"socketId": null,
"socketIoCookie": "__socket.io",
"socketIoRoute": "/__socket.io",
"xhrRoute": "/xhrs/"
}

exports['src/index .getPublicConfigKeys returns list of public config keys 1'] = [
"animationDistanceThreshold",
"baseUrl",
"blockHosts",
"chromeWebSecurity",
"clientCertificates",
"component",
"componentFolder",
"defaultCommandTimeout",
"downloadsFolder",
"e2e",
"env",
"execTimeout",
"experimentalFetchPolyfill",
"experimentalInteractiveRunEvents",
"experimentalSessionSupport",
"experimentalSourceRewriting",
"experimentalStudio",
"fileServerFolder",
"fixturesFolder",
"ignoreTestFiles",
"includeShadowDom",
"integrationFolder",
"modifyObstructiveCode",
"nodeVersion",
"numTestsKeptInMemory",
"pageLoadTimeout",
"pluginsFile",
"port",
"projectId",
"redirectionLimit",
"reporter",
"reporterOptions",
"requestTimeout",
"resolvedNodePath",
"resolvedNodeVersion",
"responseTimeout",
"retries",
"screenshotOnRunFailure",
"screenshotsFolder",
"slowTestThreshold",
"scrollBehavior",
"supportFile",
"supportFolder",
"taskTimeout",
"testFiles",
"trashAssetsBeforeRuns",
"userAgent",
"video",
"videoCompression",
"videosFolder",
"videoUploadOnPasses",
"viewportHeight",
"viewportWidth",
"waitForAnimations",
"watchForFileChanges",
"browsers",
"hosts",
"modifyObstructiveCode"
]
157 changes: 157 additions & 0 deletions packages/config/__snapshots__/validation_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
exports['undefined browsers'] = `
Missing browsers list
`

exports['empty list of browsers'] = `
Expected at least one browser
`

exports['browsers list with a string'] = `
Found an error while validating the \`browsers\` list. Expected \`name\` to be a non-empty string. Instead the value was: \`"foo"\`
`

exports['src/validation .isValidBrowser passes valid browsers and forms error messages for invalid ones isValidBrowser 1'] = {
"name": "isValidBrowser",
"behavior": [
{
"given": {
"name": "Chrome",
"displayName": "Chrome Browser",
"family": "chromium",
"path": "/path/to/chrome",
"version": "1.2.3",
"majorVersion": 1
},
"expect": true
},
{
"given": {
"name": "FF",
"displayName": "Firefox",
"family": "firefox",
"path": "/path/to/firefox",
"version": "1.2.3",
"majorVersion": "1"
},
"expect": true
},
{
"given": {
"name": "Electron",
"displayName": "Electron",
"family": "chromium",
"path": "",
"version": "99.101.3",
"majorVersion": 99
},
"expect": true
},
{
"given": {
"name": "No display name",
"family": "chromium"
},
"expect": "Expected `displayName` to be a non-empty string. Instead the value was: `{\"name\":\"No display name\",\"family\":\"chromium\"}`"
},
{
"given": {
"name": "bad family",
"displayName": "Bad family browser",
"family": "unknown family"
},
"expect": "Expected `family` to be either chromium or firefox. Instead the value was: `{\"name\":\"bad family\",\"displayName\":\"Bad family browser\",\"family\":\"unknown family\"}`"
}
]
}

exports['not one of the strings error message'] = `
Expected \`test\` to be one of these values: "foo", "bar". Instead the value was: \`"nope"\`
`

exports['number instead of string'] = `
Expected \`test\` to be one of these values: "foo", "bar". Instead the value was: \`42\`
`

exports['null instead of string'] = `
Expected \`test\` to be one of these values: "foo", "bar". Instead the value was: \`null\`
`

exports['not one of the numbers error message'] = `
Expected \`test\` to be one of these values: 1, 2, 3. Instead the value was: \`4\`
`

exports['string instead of a number'] = `
Expected \`test\` to be one of these values: 1, 2, 3. Instead the value was: \`"foo"\`
`

exports['null instead of a number'] = `
Expected \`test\` to be one of these values: 1, 2, 3. Instead the value was: \`null\`
`

exports['src/validation .isStringOrFalse returns error message when value is neither string nor false 1'] = `
Expected \`mockConfigKey\` to be a string or false. Instead the value was: \`null\`
`

exports['src/validation .isBoolean returns error message when value is a not a string 1'] = `
Expected \`mockConfigKey\` to be a string. Instead the value was: \`1\`
`

exports['src/validation .isString returns error message when value is a not a string 1'] = `
Expected \`mockConfigKey\` to be a string. Instead the value was: \`1\`
`

exports['src/validation .isArray returns error message when value is a non-array 1'] = `
Expected \`mockConfigKey\` to be an array. Instead the value was: \`1\`
`

exports['not string or array'] = `
Expected \`mockConfigKey\` to be a string or an array of strings. Instead the value was: \`null\`
`

exports['array of non-strings'] = `
Expected \`mockConfigKey\` to be a string or an array of strings. Instead the value was: \`[1,2,3]\`
`

exports['src/validation .isNumberOrFalse returns error message when value is a not number or false 1'] = `
Expected \`mockConfigKey\` to be a number or false. Instead the value was: \`null\`
`

exports['src/validation .isPlainObject returns error message when value is a not an object 1'] = `
Expected \`mockConfigKey\` to be a plain object. Instead the value was: \`1\`
`

exports['src/validation .isNumber returns error message when value is a not a number 1'] = `
Expected \`mockConfigKey\` to be a number. Instead the value was: \`"string"\`
`

exports['invalid retry value'] = `
Expected \`mockConfigKey\` to be a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls. Instead the value was: \`"1"\`
`

exports['invalid retry object'] = `
Expected \`mockConfigKey\` to be a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls. Instead the value was: \`{"fakeMode":1}\`
`

exports['src/validation .isValidClientCertificatesSet returns error message for certs not passed as an array array 1'] = `
Expected \`mockConfigKey\` to be a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls. Instead the value was: \`"1"\`
`

exports['src/validation .isValidClientCertificatesSet returns error message for certs object without url 1'] = `
Expected \`clientCertificates[0].url\` to be a URL matcher. Instead the value was: \`undefined\`
`

exports['missing https protocol'] = `
Expected \`clientCertificates[0].url\` to be an https protocol. Instead the value was: \`"http://url.com"\`
`

exports['invalid url'] = `
Expected \`clientCertificates[0].url\` to be a valid URL. Instead the value was: \`"not *"\`
`

exports['not qualified url'] = `
Expected \`mockConfigKey\` to be a fully qualified URL (starting with \`http://\` or \`https://\`). Instead the value was: \`"url.com"\`
`

exports['empty string'] = `
Expected \`mockConfigKey\` to be a fully qualified URL (starting with \`http://\` or \`https://\`). Instead the value was: \`""\`
`