-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create config package for config validation (#18589)
- Loading branch information
1 parent
628202e
commit 99c8d46
Showing
65 changed files
with
5,205 additions
and
1,193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": [ | ||
"../../.eslintrc.json" | ||
], | ||
"parser": "@typescript-eslint/parser" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: \`""\` | ||
` |
Oops, something went wrong.
99c8d46
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
linux x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
99c8d46
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
darwin x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally: