Skip to content

Commit

Permalink
feat: allow users to pass true to videoCompression config and only a… (
Browse files Browse the repository at this point in the history
…#26810)

* chore: allow users to pass true to videoCompression config and only allow valudes 1-51 inclusively to be passed in

* run ci

* chore: allow zero to be option for CRF as we will coerve it to false and skip compression to have a lossless video, which has the same effect

* Update cli/CHANGELOG.md

* chore: update videoCompression types

* chore: update changelog

* Update cli/CHANGELOG.md

* Update cli/types/cypress.d.ts

Co-authored-by: Emily Rohrbough <emilyrohrbough@users.noreply.github.com>

* Update packages/config/src/validation.ts

Co-authored-by: Emily Rohrbough <emilyrohrbough@users.noreply.github.com>

* chore: update config snapshots

* Update packages/config/test/validation.spec.ts

Co-authored-by: Emily Rohrbough <emilyrohrbough@users.noreply.github.com>

* chore: add system test on videoCompression=true coersion

* chore: document 0 as being false and not a valid CRF option for cypress video compression and make CRF valid values 1-51

* chore: fix types

* chore: fix types

* chore: fix change to log as feature and not bugfix

* chore: fix server side unit tests

---------

Co-authored-by: Emily Rohrbough <emilyrohrbough@users.noreply.github.com>
  • Loading branch information
AtofStryker and emilyrohrbough authored Jun 8, 2023
1 parent 0be33b9 commit 6b7683e
Show file tree
Hide file tree
Showing 12 changed files with 399 additions and 131 deletions.
4 changes: 4 additions & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

_Released 06/20/2023 (PENDING)_

**Features:**

- The [`videoCompression`](https://docs.cypress.io/guides/references/configuration#Videos) configuration option now accepts both a boolean or a Constant Rate Factor (CRF) number between `1` and `51`. The `videoCompression` default value is still `32` CRF and when `videoCompression` is set to `true` the default of `32` CRF will be used. Addresses [#26658](https://github.com/cypress-io/cypress/issues/26658).

**Bugfixes:**

- Fixed an issue where video output was not being logged to the console when `videoCompression` was turned off. Videos will now log to the terminal regardless of the compression value. Addresses [#25945](https://github.com/cypress-io/cypress/issues/25945).
Expand Down
7 changes: 5 additions & 2 deletions cli/types/cypress.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3004,10 +3004,13 @@ declare namespace Cypress {
*/
trashAssetsBeforeRuns: boolean
/**
* The quality setting for the video compression, in Constant Rate Factor (CRF). The value can be false to disable compression or a value between 0 and 51, where a lower value results in better quality (at the expense of a higher file size).
* The quality setting for the video compression, in Constant Rate Factor (CRF).
* Enable compression by passing true to use the default CRF of 32.
* Compress at custom CRF by passing a number between 1 and 51, where a lower value results in better quality (at the expense of a higher file size).
* Disable compression by passing false or 0.
* @default 32
*/
videoCompression: number | false
videoCompression: number | boolean
/**
* Whether Cypress will record a video of the test run when running headlessly.
* @default true
Expand Down
2 changes: 1 addition & 1 deletion cli/types/tests/plugins-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const pluginConfig2: Cypress.PluginConfig = (on, config) => {
config.configFile // $ExpectType string
config.fixturesFolder // $ExpectType string | false
config.screenshotsFolder // $ExpectType string | false
config.videoCompression // $ExpectType number | false
config.videoCompression // $ExpectType number | boolean
config.projectRoot // $ExpectType string
config.version // $ExpectType string
config.testingType // $ExpectType TestingType
Expand Down
260 changes: 136 additions & 124 deletions packages/config/__snapshots__/validation.spec.ts.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
exports['missing https protocol'] = {
"key": "clientCertificates[0].url",
"value": "http://url.com",
"type": "an https protocol"
'key': 'clientCertificates[0].url',
'value': 'http://url.com',
'type': 'an https protocol',
}

exports['invalid url'] = {
"key": "clientCertificates[0].url",
"value": "not *",
"type": "a valid URL"
'key': 'clientCertificates[0].url',
'value': 'not *',
'type': 'a valid URL',
}

exports['undefined browsers'] = `
Expand All @@ -19,208 +19,220 @@ Expected at least one browser
`

exports['browsers list with a string'] = {
"key": "name",
"value": "foo",
"type": "a non-empty string",
"list": "browsers"
'key': 'name',
'value': 'foo',
'type': 'a non-empty string',
'list': 'browsers',
}

exports['invalid retry value'] = {
"key": "mockConfigKey",
"value": "1",
"type": "a positive number or null or an object with keys \"openMode\" and \"runMode\" with values of numbers or nulls"
'key': 'mockConfigKey',
'value': '1',
'type': 'a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls',
}

exports['invalid retry object'] = {
"key": "mockConfigKey",
"value": {
"fakeMode": 1
'key': 'mockConfigKey',
'value': {
'fakeMode': 1,
},
"type": "a positive number or null or an object with keys \"openMode\" and \"runMode\" with values of numbers or nulls"
'type': 'a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls',
}

exports['not qualified url'] = {
"key": "mockConfigKey",
"value": "url.com",
"type": "a fully qualified URL (starting with `http://` or `https://`)"
'key': 'mockConfigKey',
'value': 'url.com',
'type': 'a fully qualified URL (starting with `http://` or `https://`)',
}

exports['empty string'] = {
"key": "mockConfigKey",
"value": "",
"type": "a fully qualified URL (starting with `http://` or `https://`)"
'key': 'mockConfigKey',
'value': '',
'type': 'a fully qualified URL (starting with `http://` or `https://`)',
}

exports['not string or array'] = {
"key": "mockConfigKey",
"value": null,
"type": "a string or an array of strings"
'key': 'mockConfigKey',
'value': null,
'type': 'a string or an array of strings',
}

exports['array of non-strings'] = {
"key": "mockConfigKey",
"value": [
'key': 'mockConfigKey',
'value': [
1,
2,
3
3,
],
"type": "a string or an array of strings"
'type': 'a string or an array of strings',
}

exports['not one of the strings error message'] = {
"key": "test",
"value": "nope",
"type": "one of these values: \"foo\", \"bar\""
'key': 'test',
'value': 'nope',
'type': 'one of these values: "foo", "bar"',
}

exports['number instead of string'] = {
"key": "test",
"value": 42,
"type": "one of these values: \"foo\", \"bar\""
'key': 'test',
'value': 42,
'type': 'one of these values: "foo", "bar"',
}

exports['null instead of string'] = {
"key": "test",
"value": null,
"type": "one of these values: \"foo\", \"bar\""
'key': 'test',
'value': null,
'type': 'one of these values: "foo", "bar"',
}

exports['not one of the numbers error message'] = {
"key": "test",
"value": 4,
"type": "one of these values: 1, 2, 3"
'key': 'test',
'value': 4,
'type': 'one of these values: 1, 2, 3',
}

exports['string instead of a number'] = {
"key": "test",
"value": "foo",
"type": "one of these values: 1, 2, 3"
'key': 'test',
'value': 'foo',
'type': 'one of these values: 1, 2, 3',
}

exports['null instead of a number'] = {
"key": "test",
"value": null,
"type": "one of these values: 1, 2, 3"
'key': 'test',
'value': null,
'type': 'one of these values: 1, 2, 3',
}

exports['config/src/validation .isValidClientCertificatesSet returns error message for certs not passed as an array array 1'] = {
"key": "mockConfigKey",
"value": "1",
"type": "a positive number or null or an object with keys \"openMode\" and \"runMode\" with values of numbers or nulls"
'key': 'mockConfigKey',
'value': '1',
'type': 'a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls',
}

exports['config/src/validation .isValidClientCertificatesSet returns error message for certs object without url 1'] = {
"key": "clientCertificates[0].url",
"type": "a URL matcher"
'key': 'clientCertificates[0].url',
'type': 'a URL matcher',
}

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

exports['config/src/validation .isPlainObject returns error message when value is a not an object 1'] = {
"key": "mockConfigKey",
"value": 1,
"type": "a plain object"
'key': 'mockConfigKey',
'value': 1,
'type': 'a plain object',
}

exports['config/src/validation .isNumber returns error message when value is a not a number 1'] = {
"key": "mockConfigKey",
"value": "string",
"type": "a number"
'key': 'mockConfigKey',
'value': 'string',
'type': 'a number',
}

exports['config/src/validation .isNumberOrFalse returns error message when value is a not number or false 1'] = {
"key": "mockConfigKey",
"value": null,
"type": "a number or false"
'key': 'mockConfigKey',
'value': null,
'type': 'a number or false',
}

exports['config/src/validation .isBoolean returns error message when value is a not a string 1'] = {
"key": "mockConfigKey",
"value": 1,
"type": "a string"
'key': 'mockConfigKey',
'value': 1,
'type': 'a string',
}

exports['config/src/validation .isString returns error message when value is a not a string 1'] = {
"key": "mockConfigKey",
"value": 1,
"type": "a string"
'key': 'mockConfigKey',
'value': 1,
'type': 'a string',
}

exports['config/src/validation .isArray returns error message when value is a non-array 1'] = {
"key": "mockConfigKey",
"value": 1,
"type": "an array"
'key': 'mockConfigKey',
'value': 1,
'type': 'an array',
}

exports['config/src/validation .isStringOrFalse returns error message when value is neither string nor false 1'] = {
"key": "mockConfigKey",
"value": null,
"type": "a string or false"
'key': 'mockConfigKey',
'value': null,
'type': 'a string or false',
}

exports['invalid lower bound'] = {
'key': 'test',
'value': -1,
'type': 'a valid CRF number between 1 & 51, 0 or false to disable compression, or true to use the default compression of 32',
}

exports['invalid upper bound'] = {
'key': 'test',
'value': 52,
'type': 'a valid CRF number between 1 & 51, 0 or false to disable compression, or true to use the default compression of 32',
}
Loading

10 comments on commit 6b7683e

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6b7683e Jun 8, 2023

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 arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.15.0/linux-arm64/develop-6b7683e483aa0dc914470564f8a45f465fb6940d/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6b7683e Jun 8, 2023

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 build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.15.0/linux-x64/develop-6b7683e483aa0dc914470564f8a45f465fb6940d/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6b7683e Jun 8, 2023

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 arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.15.0/darwin-arm64/develop-6b7683e483aa0dc914470564f8a45f465fb6940d/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6b7683e Jun 8, 2023

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 build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.15.0/darwin-x64/develop-6b7683e483aa0dc914470564f8a45f465fb6940d/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6b7683e Jun 8, 2023

Choose a reason for hiding this comment

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

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.15.0/win32-x64/develop-6b7683e483aa0dc914470564f8a45f465fb6940d/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6b7683e Jun 9, 2023

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 arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.15.0/linux-arm64/develop-6b7683e483aa0dc914470564f8a45f465fb6940d/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6b7683e Jun 9, 2023

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 build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.15.0/linux-x64/develop-6b7683e483aa0dc914470564f8a45f465fb6940d/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6b7683e Jun 9, 2023

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 build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.15.0/darwin-x64/develop-6b7683e483aa0dc914470564f8a45f465fb6940d/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6b7683e Jun 9, 2023

Choose a reason for hiding this comment

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

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.15.0/win32-x64/develop-6b7683e483aa0dc914470564f8a45f465fb6940d/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 6b7683e Jun 9, 2023

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 arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.15.0/darwin-arm64/develop-6b7683e483aa0dc914470564f8a45f465fb6940d/cypress.tgz

Please sign in to comment.