-
Notifications
You must be signed in to change notification settings - Fork 3.4k
feat: create config package for config validation #18589
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
Changes from all commits
5443611
045fde3
14632cc
b92b3b1
dcfaa5b
a8e405e
c7440d1
acd4b77
8fb03ab
f149559
e723b03
d843170
a38fb6a
3fdd15c
4bfcfae
5e52676
d0a9967
82b1119
ba6d586
00fed44
91dfd3f
6826069
f449b9d
c64a652
eae59f8
63d18cf
402a393
f279e36
904c22b
1af43ac
b4ce459
c3ec924
762470c
3486ab1
eafacca
a12e5d2
ffc43c5
9e37c63
cd13f0e
2b517be
953dacd
e05ceb3
d4d4354
39dadca
766502c
4a34493
f0676e2
2e27112
ab89639
530e19d
b351eda
35fc415
8bdfd57
619ee85
a28cd4f
c0a47ca
eaead0d
4905d32
5cb2f5e
f582b3c
f0d538a
b804ea3
1052df3
537e583
84f53d1
d97e70f
2e62654
5bad91c
b6b3e7c
db58a8c
5ddf2dd
f554233
e4c351d
7341dec
1414fd7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Right now I'm not sure they run in CI. I don't see them in (why do we have a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good call: |
||
"clean-deps": "find . -depth -name node_modules -type d -exec rm -rf {} \\;", | ||
"clean-untracked-files": "git clean -d -f", | ||
"precypress:open": "yarn ensure-deps", | ||
|
@@ -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}'\"", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": [ | ||
"../../.eslintrc.json" | ||
], | ||
"parser": "@typescript-eslint/parser" | ||
} |
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 | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
exports['src/index .getBreakingKeys returns list of breaking config keys 1'] = [ | ||
"blacklistHosts", | ||
"experimentalComponentTesting", | ||
"experimentalGetCookiesSameSite", | ||
"experimentalNetworkStubbing", | ||
"experimentalRunEvents", | ||
"experimentalShadowDomSupport", | ||
"firefoxGcInterval", | ||
"nodeVersion", | ||
"nodeVersion" | ||
] | ||
|
||
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, | ||
"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" | ||
] |
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: \`""\` | ||
` |
Uh oh!
There was an error while loading. Please reload this page.