Skip to content

Commit 8d016dd

Browse files
Merge branch 'develop' into remove-create-on-server-ts
2 parents fe91a9e + 6109dc8 commit 8d016dd

Some content is hidden

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

60 files changed

+1747
-955
lines changed

.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,35 @@ cypress.zip
1313
Cached Theme.pak
1414
Cached Theme Material Design.pak
1515

16+
# from data-context, compiled .js files
17+
packages/data-context/src/**/*.js
18+
1619
# from desktop-gui
1720
packages/desktop-gui/cypress/videos
1821
packages/desktop-gui/src/jsconfig.json
1922

23+
2024
# from driver
2125
packages/driver/cypress/videos
2226
packages/driver/cypress/screenshots
2327

28+
# from launcher, compiled .js files
29+
packages/launcher/index.js
30+
packages/launcher/lib/**/*.js
31+
32+
# from network, compiled .js files
33+
packages/network/lib/**/*.js
34+
35+
# from net-stubbing, compiled .js files
36+
packages/net-stubbing/lib/**/*.js
37+
2438
# from runner
2539
packages/runner/cypress/videos
2640
packages/runner/cypress/screenshots
2741

42+
# from proxy, compiled .js files
43+
packages/proxy/lib/**/*.js
44+
2845
# npm packages
2946
npm/**/cypress/screenshots
3047

@@ -33,13 +50,20 @@ packages/example/app
3350
packages/example/build
3451
packages/example/cypress/integration
3552

53+
# from frontend-shared
54+
packages/frontend-shared/cypress/e2e/.projects
55+
packages/frontend-shared/src/public/shiki/themes/cypress.theme.json
56+
3657
# from server
3758
packages/server/.cy
3859
packages/server/.projects
3960
packages/server/support
4061
packages/server/test/support/fixtures/server/imgs
4162
packages/server/test/support/fixtures/server/libs
4263

64+
# from socket, dist built files
65+
packages/socket/lib/*.js
66+
4367
# from system-tests
4468
system-tests/.projects
4569
system-tests/fixtures/large-img
@@ -57,6 +81,10 @@ system-tests/fixtures/large-img
5781
# from runner-ct
5882
/packages/runner-ct/cypress/screenshots
5983

84+
# graphql, auto-generated
85+
/packages/launchpad/src/generated
86+
/packages/app/src/generated
87+
6088
# from npm/create-cypress-tests
6189
/npm/create-cypress-tests/initial-template
6290
/npm/create-cypress-tests/src/test-output
@@ -343,3 +371,7 @@ $RECYCLE.BIN/
343371

344372
# Circle cache artifacts
345373
globbed_node_modules
374+
375+
# Autogenerated files, typically from graphql-code-generator
376+
*.gen.ts
377+
*.gen.json

browser-versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"chrome:beta": "95.0.4638.54",
2+
"chrome:beta": "96.0.4664.27",
33
"chrome:stable": "95.0.4638.54"
44
}

cli/schema/cypress.schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@
4444
"default": null,
4545
"description": "The reporter options used. Supported options depend on the reporter. See https://on.cypress.io/reporters#Reporter-Options"
4646
},
47+
"slowTestThreshold": {
48+
"type": "number",
49+
"default": 10000,
50+
"description": "Slow test threshold in milliseconds. Only affects the visual output of some reporters. For example, the spec reporter will display the test time in yellow if over the threshold. See https://on.cypress.io/configuration#Timeouts"
51+
},
4752
"testFiles": {
4853
"type": [
4954
"string",

cli/types/cypress-npm-api.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ declare namespace CypressCommandLine {
9191
* Specify mocha reporter options
9292
*/
9393
reporterOptions: any
94+
/**
95+
* Slow test threshold in milliseconds. Only affects the visual output of some reporters. For example, the spec reporter will display the test time in yellow if over the threshold.
96+
*/
97+
slowTestThreshold: number
9498
/**
9599
* Specify the specs to run
96100
*/

cli/types/cypress.d.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2577,6 +2577,11 @@ declare namespace Cypress {
25772577
* @default "spec"
25782578
*/
25792579
reporterOptions: { [key: string]: any }
2580+
/**
2581+
* Slow test threshold in milliseconds. Only affects the visual output of some reporters. For example, the spec reporter will display the test time in yellow if over the threshold.
2582+
* @default 10000
2583+
*/
2584+
slowTestThreshold: number
25802585
/**
25812586
* Whether Cypress will watch and restart tests on test file changes
25822587
* @default true
@@ -5672,7 +5677,7 @@ declare namespace Cypress {
56725677
xhr: XMLHttpRequest
56735678
}
56745679

5675-
type Encodings = 'ascii' | 'base64' | 'binary' | 'hex' | 'latin1' | 'utf8' | 'utf-8' | 'ucs2' | 'ucs-2' | 'utf16le' | 'utf-16le'
5680+
type Encodings = 'ascii' | 'base64' | 'binary' | 'hex' | 'latin1' | 'utf8' | 'utf-8' | 'ucs2' | 'ucs-2' | 'utf16le' | 'utf-16le' | null
56765681
type PositionType = 'topLeft' | 'top' | 'topRight' | 'left' | 'center' | 'right' | 'bottomLeft' | 'bottom' | 'bottomRight'
56775682
type ViewportPreset = 'macbook-16' | 'macbook-15' | 'macbook-13' | 'macbook-11' | 'ipad-2' | 'ipad-mini' | 'iphone-xr' | 'iphone-x' | 'iphone-6+' | 'iphone-se2' | 'iphone-8' | 'iphone-7' | 'iphone-6' | 'iphone-5' | 'iphone-4' | 'iphone-3' | 'samsung-s10' | 'samsung-note9'
56785683
interface Offset {

npm/react/plugins/next/getRunWebpackSpan.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,21 @@ import type { Span } from 'next/dist/telemetry/trace/trace'
33
// Starting with v11.1.1, a trace is required.
44
// 'next/dist/telemetry/trace/trace' only exists since v10.0.9
55
// and our peerDeps support back to v8 so try-catch this import
6+
// Starting from 12.0 trace is now located in 'next/dist/trace/trace'
67
export async function getRunWebpackSpan (): Promise<{ runWebpackSpan?: Span }> {
78
let trace: (name: string) => Span
89

910
try {
10-
trace = await import('next/dist/telemetry/trace/trace').then((m) => m.trace)
11+
try {
12+
trace = await import('next/dist/telemetry/trace/trace').then((m) => m.trace)
1113

12-
return { runWebpackSpan: trace('cypress') }
14+
return { runWebpackSpan: trace('cypress') }
15+
} catch (_) {
16+
// @ts-ignore
17+
trace = await import('next/dist/trace/trace').then((m) => m.trace)
18+
19+
return { runWebpackSpan: trace('cypress') }
20+
}
1321
} catch (_) {
1422
return {}
1523
}

npm/vite-dev-server/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# [@cypress/vite-dev-server-v2.2.0](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v2.1.1...@cypress/vite-dev-server-v2.2.0) (2021-10-15)
2+
3+
4+
### Features
5+
6+
* normalized signatures webpack & vite servers ([#18379](https://github.com/cypress-io/cypress/issues/18379)) ([8f5308f](https://github.com/cypress-io/cypress/commit/8f5308f7068b80fb877da539ce34fb67ba497c4f))
7+
18
# [@cypress/vite-dev-server-v2.1.1](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v2.1.0...@cypress/vite-dev-server-v2.1.1) (2021-10-04)
29

310

npm/webpack-dev-server/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# [@cypress/webpack-dev-server-v1.7.0](https://github.com/cypress-io/cypress/compare/@cypress/webpack-dev-server-v1.6.0...@cypress/webpack-dev-server-v1.7.0) (2021-10-15)
2+
3+
4+
### Features
5+
6+
* normalized signatures webpack & vite servers ([#18379](https://github.com/cypress-io/cypress/issues/18379)) ([8f5308f](https://github.com/cypress-io/cypress/commit/8f5308f7068b80fb877da539ce34fb67ba497c4f))
7+
18
# [@cypress/webpack-dev-server-v1.6.0](https://github.com/cypress-io/cypress/compare/@cypress/webpack-dev-server-v1.5.0...@cypress/webpack-dev-server-v1.6.0) (2021-09-10)
29

310

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cypress",
3-
"version": "8.6.0",
3+
"version": "8.7.0",
44
"description": "Cypress.io end to end testing tool",
55
"private": true,
66
"scripts": {

packages/driver/cypress/integration/commands/files_spec.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,22 @@ describe('src/cy/commands/files', () => {
3737
})
3838
})
3939

40+
// https://github.com/cypress-io/cypress/issues/1558
41+
it('passes explicit null encoding through to server and decodes response', () => {
42+
Cypress.backend.resolves({
43+
contents: Buffer.from('\n'),
44+
filePath: '/path/to/foo.json',
45+
})
46+
47+
cy.readFile('foo.json', null).then(() => {
48+
expect(Cypress.backend).to.be.calledWith(
49+
'read:file',
50+
'foo.json',
51+
{ encoding: null },
52+
)
53+
}).should('eql', Buffer.from('\n'))
54+
})
55+
4056
it('sets the contents as the subject', () => {
4157
Cypress.backend.resolves(okResponse)
4258

@@ -340,6 +356,23 @@ describe('src/cy/commands/files', () => {
340356
})
341357
})
342358

359+
// https://github.com/cypress-io/cypress/issues/1558
360+
it('explicit null encoding is sent to server as Buffer', () => {
361+
Cypress.backend.resolves(okResponse)
362+
363+
cy.writeFile('foo.txt', Buffer.from([0, 0, 54, 255]), null).then(() => {
364+
expect(Cypress.backend).to.be.calledWith(
365+
'write:file',
366+
'foo.txt',
367+
Buffer.from([0, 0, 54, 255]),
368+
{
369+
encoding: null,
370+
flag: 'w',
371+
},
372+
)
373+
})
374+
})
375+
343376
it('can take encoding as part of options', () => {
344377
Cypress.backend.resolves(okResponse)
345378

packages/driver/cypress/integration/commands/fixtures_spec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@ describe('src/cy/commands/fixtures', () => {
3535
})
3636
})
3737

38+
// https://github.com/cypress-io/cypress/issues/1558
39+
it('passes explicit null encoding through to server and decodes response', () => {
40+
Cypress.backend.withArgs('get:fixture').resolves(Buffer.from('\n'))
41+
42+
cy.fixture('foo', null).then((obj) => {
43+
expect(Cypress.backend).to.be.calledWith('get:fixture', 'foo', {
44+
encoding: null,
45+
})
46+
}).should('eql', Buffer.from('\n'))
47+
})
48+
3849
it('can have encoding as second argument and options as third argument', () => {
3950
Cypress.backend.withArgs('get:fixture').resolves({ foo: 'bar' })
4051

packages/driver/src/cy/commands/files.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,16 @@ export default (Commands, Cypress, cy) => {
1111

1212
if (_.isObject(encoding)) {
1313
userOptions = encoding
14-
encoding = null
14+
encoding = undefined
1515
}
1616

1717
options = _.defaults({}, userOptions, {
18-
encoding: encoding != null ? encoding : 'utf8',
18+
// https://github.com/cypress-io/cypress/issues/1558
19+
// If no encoding is specified, then Cypress has historically defaulted
20+
// to `utf8`, because of it's focus on text files. This is in contrast to
21+
// NodeJs, which defaults to binary. We allow users to pass in `null`
22+
// to restore the default node behavior.
23+
encoding: encoding === undefined ? 'utf8' : encoding,
1924
log: true,
2025
})
2126

@@ -53,6 +58,14 @@ export default (Commands, Cypress, cy) => {
5358
args: { cmd: 'readFile', action: 'read', file, filePath: err.filePath, error: err.message },
5459
})
5560
}).then(({ contents, filePath }) => {
61+
// https://github.com/cypress-io/cypress/issues/1558
62+
// We invoke Buffer.from() in order to transform this from an ArrayBuffer -
63+
// which socket.io uses to transfer the file over the websocket - into a
64+
// `Buffer`, which webpack polyfills in the browser.
65+
if (options.encoding === null) {
66+
contents = Buffer.from(contents)
67+
}
68+
5669
consoleProps['File Path'] = filePath
5770
consoleProps['Contents'] = contents
5871

@@ -85,11 +98,16 @@ export default (Commands, Cypress, cy) => {
8598

8699
if (_.isObject(encoding)) {
87100
userOptions = encoding
88-
encoding = null
101+
encoding = undefined
89102
}
90103

91104
options = _.defaults({}, userOptions, {
92-
encoding: encoding ? encoding : 'utf8',
105+
// https://github.com/cypress-io/cypress/issues/1558
106+
// If no encoding is specified, then Cypress has historically defaulted
107+
// to `utf8`, because of it's focus on text files. This is in contrast to
108+
// NodeJs, which defaults to binary. We allow users to pass in `null`
109+
// to restore the default node behavior.
110+
encoding: encoding === undefined ? 'utf8' : encoding,
93111
flag: userOptions.flag ? userOptions.flag : 'w',
94112
log: true,
95113
})
@@ -120,7 +138,7 @@ export default (Commands, Cypress, cy) => {
120138
})
121139
}
122140

123-
if (_.isObject(contents)) {
141+
if (_.isObject(contents) && !Buffer.isBuffer(contents)) {
124142
contents = JSON.stringify(contents, null, 2)
125143
}
126144

packages/driver/src/cy/commands/fixtures.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import Promise from 'bluebird'
66
import $errUtils from '../../cypress/error_utils'
77

88
const clone = (obj) => {
9+
if (Buffer.isBuffer(obj)) {
10+
return Buffer.from(obj)
11+
}
12+
913
return JSON.parse(JSON.stringify(obj))
1014
}
1115

@@ -47,7 +51,7 @@ export default (Commands, Cypress, cy, state, config) => {
4751
options = args[1]
4852
}
4953

50-
if (_.isString(args[0])) {
54+
if (_.isString(args[0]) || args[0] === null) {
5155
options.encoding = args[0]
5256
}
5357

@@ -64,6 +68,18 @@ export default (Commands, Cypress, cy, state, config) => {
6468
return $errUtils.throwErr(response.__error)
6569
}
6670

71+
// https://github.com/cypress-io/cypress/issues/1558
72+
// We invoke Buffer.from() in order to transform this from an ArrayBuffer -
73+
// which socket.io uses to transfer the file over the websocket - into a
74+
// `Buffer`, which webpack polyfills in the browser.
75+
if (options.encoding === null) {
76+
response = Buffer.from(response)
77+
} else if (response instanceof ArrayBuffer) {
78+
// Cypress' behavior is to base64 encode binary files if the user
79+
// doesn't explicitly pass `null` as the encoding.
80+
response = Buffer.from(response).toString('base64')
81+
}
82+
6783
// add the fixture to the cache
6884
// so it can just be returned next time
6985
cache[fixture] = response

packages/driver/src/cypress/mocha.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,8 @@ const create = (specWindow, Cypress, config) => {
500500

501501
const _mocha = createMocha(specWindow)
502502

503+
_mocha.slow(config('slowTestThreshold'))
504+
503505
const _runner = getRunner(_mocha)
504506

505507
_mocha.suite.file = Cypress.spec.relative

packages/driver/src/cypress/runner.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const TEST_BEFORE_RUN_EVENT = 'runner:test:before:run'
2121
const TEST_AFTER_RUN_EVENT = 'runner:test:after:run'
2222

2323
const RUNNABLE_LOGS = 'routes agents commands hooks'.split(' ')
24-
const RUNNABLE_PROPS = '_testConfig id order title _titlePath root hookName hookId err state failedFromHookId body speed type duration wallClockStartedAt wallClockDuration timings file originalTitle invocationDetails final currentRetry retries'.split(' ')
24+
const RUNNABLE_PROPS = '_testConfig id order title _titlePath root hookName hookId err state failedFromHookId body speed type duration wallClockStartedAt wallClockDuration timings file originalTitle invocationDetails final currentRetry retries _slow'.split(' ')
2525

2626
const debug = debugFn('cypress:driver:runner')
2727
const debugErrors = debugFn('cypress:driver:errors')
@@ -581,6 +581,10 @@ const normalize = (runnable, tests, initialTests, onRunnable, onLogsById, getRun
581581
wrappedRunnable._testConfig = cfg
582582
}
583583

584+
if (cfg.slowTestThreshold) {
585+
runnable.slow(cfg.slowTestThreshold)
586+
}
587+
584588
wrappedRunnable._titlePath = runnable.titlePath()
585589
}
586590

0 commit comments

Comments
 (0)