Skip to content

Commit 713932e

Browse files
committed
Merge branch 'develop' of github.com:cypress-io/cypress into misc/use_webdriver
2 parents 31192bc + 8cff956 commit 713932e

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

cli/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ _Released 10/1/2024 (PENDING)_
77

88
- Cypress now consumes [geckodriver](https://firefox-source-docs.mozilla.org/testing/geckodriver/index.html) to help automate the Firefox browser instead of [marionette-client](https://github.com/cypress-io/marionette-client). Addresses [#30217](https://github.com/cypress-io/cypress/issues/30217).
99
- Cypress now consumes [webdriver](https://github.com/webdriverio/webdriverio/tree/main/packages/webdriver) to help automate the Firefox browser and [firefox-profile](https://github.com/saadtazi/firefox-profile-js) to create a firefox profile and convert it to Base64 to save user screen preferences via `xulstore.json`. Addresses [#30300](https://github.com/cypress-io/cypress/issues/30300) and [#30301](https://github.com/cypress-io/cypress/issues/30301).
10+
- Pass spec information to protocol's `beforeSpec` to improve troubleshooting when reporting on errors. Addressed in [#30316](https://github.com/cypress-io/cypress/pull/30316).
1011

1112
## 13.15.0
1213

packages/server/lib/cloud/protocol.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import env from '../util/env'
1414
import { putProtocolArtifact } from './api/put_protocol_artifact'
1515

1616
import type { Readable } from 'stream'
17-
import type { ProtocolManagerShape, AppCaptureProtocolInterface, CDPClient, ProtocolError, CaptureArtifact, ProtocolErrorReport, ProtocolCaptureMethod, ProtocolManagerOptions, ResponseStreamOptions, ResponseEndedWithEmptyBodyOptions, ResponseStreamTimedOutOptions, AfterSpecDurations } from '@packages/types'
17+
import type { ProtocolManagerShape, AppCaptureProtocolInterface, CDPClient, ProtocolError, CaptureArtifact, ProtocolErrorReport, ProtocolCaptureMethod, ProtocolManagerOptions, ResponseStreamOptions, ResponseEndedWithEmptyBodyOptions, ResponseStreamTimedOutOptions, AfterSpecDurations, SpecWithRelativeRoot } from '@packages/types'
1818

1919
const routes = require('./routes')
2020

@@ -133,7 +133,7 @@ export class ProtocolManager implements ProtocolManagerShape {
133133
this.invokeSync('addRunnables', { isEssential: true }, runnables)
134134
}
135135

136-
beforeSpec (spec: { instanceId: string }) {
136+
beforeSpec (spec: SpecWithRelativeRoot & { instanceId: string }) {
137137
this._afterSpecDurations = undefined
138138

139139
if (!this._protocol) {
@@ -157,7 +157,7 @@ export class ProtocolManager implements ProtocolManagerShape {
157157
}
158158
}
159159

160-
private _beforeSpec (spec: { instanceId: string }) {
160+
private _beforeSpec (spec: SpecWithRelativeRoot & { instanceId: string }) {
161161
this._instanceId = spec.instanceId
162162
const cypressProtocolDirectory = path.join(os.tmpdir(), 'cypress', 'protocol')
163163
const archivePath = path.join(cypressProtocolDirectory, `${spec.instanceId}.tar`)
@@ -172,7 +172,7 @@ export class ProtocolManager implements ProtocolManagerShape {
172172

173173
this._db = db
174174
this._archivePath = archivePath
175-
this.invokeSync('beforeSpec', { isEssential: true }, { workingDirectory: cypressProtocolDirectory, archivePath, dbPath, db })
175+
this.invokeSync('beforeSpec', { isEssential: true }, { workingDirectory: cypressProtocolDirectory, archivePath, dbPath, db, spec })
176176
}
177177

178178
async afterSpec () {

packages/server/test/unit/cloud/protocol_spec.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,20 @@ describe('lib/cloud/protocol', () => {
9090
},
9191
]
9292

93-
protocolManager.beforeSpec({
93+
const spec = {
9494
instanceId: 'instanceId',
95-
})
95+
absolute: '/path/to/spec',
96+
relative: 'spec',
97+
relativeToCommonRoot: 'common/root',
98+
specFileExtension: '.ts',
99+
fileExtension: '.ts',
100+
specType: 'integration' as Cypress.CypressSpecType,
101+
baseName: 'spec',
102+
name: 'spec',
103+
fileName: 'spec.ts',
104+
}
105+
106+
protocolManager.beforeSpec(spec)
96107

97108
expect((protocolManager as any)._errors).to.be.empty
98109

@@ -101,6 +112,7 @@ describe('lib/cloud/protocol', () => {
101112
archivePath: path.join(os.tmpdir(), 'cypress', 'protocol', 'instanceId.tar'),
102113
dbPath: path.join(os.tmpdir(), 'cypress', 'protocol', 'instanceId.db'),
103114
db: mockDb,
115+
spec,
104116
})
105117

106118
expect(mockDatabase).to.be.calledWith(path.join(os.tmpdir(), 'cypress', 'protocol', 'instanceId.db'), {

packages/types/src/protocol.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type ProtocolMapping from 'devtools-protocol/types/protocol-mapping'
33
import type { IncomingHttpHeaders } from 'http'
44
import type { Readable } from 'stream'
55
import type { ProxyTimings } from './proxy'
6+
import type { SpecWithRelativeRoot } from './spec'
67

78
type Commands = ProtocolMapping.Commands
89
type Command<T extends keyof Commands> = Commands[T]
@@ -38,7 +39,7 @@ export interface AppCaptureProtocolCommon {
3839

3940
export interface AppCaptureProtocolInterface extends AppCaptureProtocolCommon {
4041
getDbMetadata (): { offset: number, size: number } | undefined
41-
beforeSpec ({ workingDirectory, archivePath, dbPath, db }: { workingDirectory: string, archivePath: string, dbPath: string, db: Database }): void
42+
beforeSpec ({ spec, workingDirectory, archivePath, dbPath, db }: { spec: SpecWithRelativeRoot & { instanceId: string }, workingDirectory: string, archivePath: string, dbPath: string, db: Database }): void
4243
uploadStallSamplingInterval: () => number
4344
}
4445

@@ -117,7 +118,7 @@ export interface ProtocolManagerShape extends AppCaptureProtocolCommon {
117118
protocolEnabled: boolean
118119
networkEnableOptions?: { maxTotalBufferSize: number, maxResourceBufferSize: number, maxPostDataSize: number }
119120
setupProtocol(script: string, options: ProtocolManagerOptions): Promise<void>
120-
beforeSpec (spec: { instanceId: string }): void
121+
beforeSpec (spec: SpecWithRelativeRoot & { instanceId: string }): void
121122
afterSpec (): Promise<{ durations: AfterSpecDurations } | undefined>
122123
reportNonFatalErrors (clientMetadata: any): Promise<void>
123124
uploadCaptureArtifact(artifact: CaptureArtifact): Promise<UploadCaptureArtifactResult | void>

0 commit comments

Comments
 (0)