Skip to content

Commit 3267b20

Browse files
committed
Merge branch 'develop' of github.com:cypress-io/cypress into chore/remove_unused_anchors
2 parents 32df4d8 + a36e181 commit 3267b20

Some content is hidden

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

50 files changed

+5607
-1432
lines changed

cli/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ _Released 11/4/2025 (PENDING)_
1515
- Fixed an issue where grouped command text jumps up and down when expanding and collapsing in the command log. Addressed in [#32757](https://github.com/cypress-io/cypress/pull/32757).
1616
- Fixed an issue with grouped console prop items having a hard to read blue color in the console log and duplicate `:` characters being displayed. Addressed in [#32776](https://github.com/cypress-io/cypress/pull/32776).
1717
- Added more context to the error message shown when `cy.prompt()` fails to download. Addressed in [#32822](https://github.com/cypress-io/cypress/pull/32822).
18+
- Fixed an issue where absolute file paths were not correctly determined from the source map when the source map root was updated. Fixes [#32809](https://github.com/cypress-io/cypress/issues/32809).
1819

1920
**Misc:**
2021

npm/vite-dev-server/cypress/e2e/vite-dev-server.cy.ts

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,27 +126,27 @@ describe('sourcemaps', () => {
126126

127127
cy.withCtx(async (ctx, o) => {
128128
await ctx.actions.file.writeFileInProject(
129-
'JsErrorSpec.cy.js',
129+
'src/JsErrorSpec.cy.js',
130130
o.testContent,
131131
)
132132

133133
await ctx.actions.file.writeFileInProject(
134-
'JsWithImportErrorSpec.cy.js',
134+
'src/JsWithImportErrorSpec.cy.js',
135135
`import React from 'react';\n\n${o.testContent}`,
136136
)
137137

138138
await ctx.actions.file.writeFileInProject(
139-
'JsxErrorSpec.cy.jsx',
139+
'src/JsxErrorSpec.cy.jsx',
140140
o.testContent,
141141
)
142142

143143
await ctx.actions.file.writeFileInProject(
144-
'TsErrorSpec.cy.ts',
144+
'src/TsErrorSpec.cy.ts',
145145
`type MyType = { value: string }\n\n${o.testContent}`,
146146
)
147147

148148
await ctx.actions.file.writeFileInProject(
149-
'TsxErrorSpec.cy.tsx',
149+
'src/TsxErrorSpec.cy.tsx',
150150
`type MyType = { value: string }\n\n${o.testContent}`,
151151
)
152152
}, { testContent })
@@ -157,7 +157,23 @@ describe('sourcemaps', () => {
157157
cy.contains(specName).click()
158158
cy.waitForSpecToFinish()
159159
cy.get('.failed > .num').should('contain', 2)
160-
cy.get('.runnable-err-file-path', { timeout: 250 }).should('contain', `${specName}:${line}:${column}`)
160+
cy.get('.runnable-err-file-path').eq(1).should('contain', `${specName}:${line}:${column}`)
161+
cy.window().then((win) => {
162+
// @ts-expect-error
163+
cy.stub(win.getEventManager(), 'emit').as('emit')
164+
})
165+
166+
cy.get('.runnable-err-file-path', { timeout: 250 }).eq(1).as('filePath')
167+
cy.get('@filePath').should('contain', `${specName}:${line}:${column}`)
168+
cy.get('@filePath').then(($el) => {
169+
$el.find('span').trigger('click')
170+
})
171+
172+
cy.get('@emit').should('have.been.calledWithMatch', 'open:file', {
173+
absoluteFile: Cypress.sinon.match(new RegExp(`cy-projects/vite7.0.0-react/src/${specName}$`)),
174+
line,
175+
column,
176+
})
161177
}
162178

163179
verifySourcemap('JsErrorSpec.cy.js', 7, 8)

npm/webpack-dev-server/cypress/e2e/webpack-dev-server.cy.ts

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/// <reference path="../support/e2e.ts" />
22

3+
import dedent from 'dedent'
4+
35
describe('Config options', () => {
46
it('supports supportFile = false', () => {
57
cy.scaffoldProject('webpack5_wds5-react')
@@ -86,3 +88,70 @@ describe('Config options', () => {
8688
cy.get('.passed > .num').should('contain', 1)
8789
})
8890
})
91+
92+
describe('sourcemaps', () => {
93+
it('should be provided for JS and transpiled files', () => {
94+
const testContent = dedent`
95+
describe('spec file with import', () => {
96+
it('should generate uncaught error', () => {
97+
throw new Error('uncaught')
98+
})
99+
100+
it('should generate failed command', () => {
101+
cy.get('#does-not-exist', { timeout: 100 })
102+
})
103+
})
104+
`
105+
106+
cy.scaffoldProject('webpack5_wds5-react')
107+
cy.openProject('webpack5_wds5-react', ['--config-file', 'cypress-webpack-no-support.config.ts', '--component'])
108+
cy.startAppServer('component')
109+
110+
cy.withCtx(async (ctx, o) => {
111+
await ctx.actions.file.writeFileInProject(
112+
'src/JsErrorSpec.cy.js',
113+
o.testContent,
114+
)
115+
116+
await ctx.actions.file.writeFileInProject(
117+
'src/JsWithImportErrorSpec.cy.js',
118+
`import React from 'react';\n\n${o.testContent}`,
119+
)
120+
121+
await ctx.actions.file.writeFileInProject(
122+
'src/JsxErrorSpec.cy.jsx',
123+
o.testContent,
124+
)
125+
}, { testContent })
126+
127+
const verifySourcemap = (specName: string, line: number, column: number) => {
128+
cy.visitApp()
129+
cy.specsPageIsVisible()
130+
cy.contains(specName).click()
131+
cy.waitForSpecToFinish()
132+
cy.get('.failed > .num').should('contain', 2)
133+
cy.window().then((win) => {
134+
// @ts-expect-error
135+
cy.stub(win.getEventManager(), 'emit').as('emit')
136+
})
137+
138+
cy.get('.runnable-err-file-path', { timeout: 250 }).eq(1).as('filePath')
139+
cy.get('@filePath').should('contain', `${specName}:${line}:${column}`)
140+
cy.get('@filePath').then(($el) => {
141+
$el.find('span').trigger('click')
142+
})
143+
144+
cy.get('@emit').should('have.been.calledWithMatch', 'open:file', {
145+
absoluteFile: Cypress.sinon.match(new RegExp(`cy-projects/webpack5_wds5-react/src/${specName}$`)),
146+
line,
147+
column,
148+
})
149+
}
150+
151+
verifySourcemap('JsErrorSpec.cy.js', 7, 8)
152+
153+
verifySourcemap('JsWithImportErrorSpec.cy.js', 9, 8)
154+
155+
verifySourcemap('JsxErrorSpec.cy.jsx', 7, 8)
156+
})
157+
})

packages/app/cypress/e2e/runner/ct-framework-errors.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function loadErrorSpec (options: Options): VerifyFunc {
4848
})
4949

5050
// Return scoped verify function with spec options baked in
51-
return createVerify({ fileName: Cypress._.last(filePath.split('/')), hasPreferredIde: false, mode: 'component' })
51+
return createVerify({ fileName: Cypress._.last(filePath.split('/')), filePath, hasPreferredIde: false, mode: 'component' })
5252
}
5353

5454
const reactVersions = [18, 19] as const

packages/app/cypress/e2e/runner/reporter-ct-generator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function loadErrorSpec (options: specLoader.LoadSpecOptions, configFile: string)
2828
specLoader.loadSpec(effectiveOptions)
2929

3030
// Return scoped verify function with spec options baked in
31-
return createVerify({ fileName: Cypress._.last(filePath.split('/')), hasPreferredIde, mode })
31+
return createVerify({ fileName: Cypress._.last(filePath.split('/')), filePath, hasPreferredIde, mode })
3232
}
3333

3434
/**

packages/app/cypress/e2e/runner/reporter.command_errors.cy.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function loadErrorSpec (options: specLoader.LoadSpecOptions): VerifyFunc {
1717
specLoader.loadSpec(options)
1818

1919
// Return scoped verify function with spec options baked in
20-
return createVerify({ fileName: Cypress._.last(filePath.split('/')), hasPreferredIde, mode })
20+
return createVerify({ filePath, fileName: Cypress._.last(filePath.split('/')), hasPreferredIde, mode })
2121
}
2222

2323
describe('errors ui', {
@@ -56,6 +56,37 @@ describe('errors ui', {
5656
})
5757
})
5858

59+
it('assertion failures with new sourcemap root', () => {
60+
const verifyWithNewSourcemapRoot = loadErrorSpec({
61+
filePath: 'errors/assertions.cy.js',
62+
hasPreferredIde: true,
63+
failCount: 3,
64+
projectName: 'runner-e2e-specs-new-sourcemap-root',
65+
configFile: 'cypress.config.mjs',
66+
})
67+
68+
verifyWithNewSourcemapRoot('with expect().<foo>', {
69+
line: 3,
70+
column: 25,
71+
message: `expected 'actual' to equal 'expected'`,
72+
verifyOpenInIde: true,
73+
})
74+
75+
verifyWithNewSourcemapRoot('with assert()', {
76+
line: 7,
77+
column: [5, 12], // [chrome, firefox]
78+
message: `should be true`,
79+
verifyOpenInIde: true,
80+
})
81+
82+
verifyWithNewSourcemapRoot('with assert.<foo>()', {
83+
line: 11,
84+
column: 12,
85+
message: `expected 'actual' to equal 'expected'`,
86+
verifyOpenInIde: true,
87+
})
88+
})
89+
5990
it('assertion failures - no preferred IDE', () => {
6091
const verify = loadErrorSpec({
6192
filePath: 'errors/assertions.cy.js',

packages/app/cypress/e2e/runner/reporter.errors.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function loadErrorSpec (options: specLoader.LoadSpecOptions): VerifyFunc {
1717
specLoader.loadSpec(options)
1818

1919
// Return scoped verify function with spec options baked in
20-
return createVerify({ fileName: Cypress._.last(filePath.split('/')), hasPreferredIde, mode })
20+
return createVerify({ fileName: Cypress._.last(filePath.split('/')), filePath, hasPreferredIde, mode })
2121
}
2222

2323
describe('errors ui', {

packages/app/cypress/e2e/runner/support/spec-loader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export type LoadSpecOptions = {
2626
failCount?: number | string
2727
pendingCount?: number | string
2828
hasPreferredIde?: boolean
29-
projectName?: 'runner-e2e-specs' | 'runner-ct-specs' | 'session-and-origin-e2e-specs' | ExperimentalRetriesProjects
29+
projectName?: 'runner-e2e-specs' | 'runner-e2e-specs-new-sourcemap-root' | 'runner-ct-specs' | 'session-and-origin-e2e-specs' | ExperimentalRetriesProjects
3030
mode?: 'e2e' | 'component'
3131
configFile?: string
3232
scaffold?: boolean

packages/app/cypress/e2e/runner/support/verify-failures.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import defaultMessages from '@packages/frontend-shared/src/locales/en-US.json'
33

44
// Assert that either the the dialog is presented or the mutation is emitted, depending on
55
// whether the test has a preferred IDE defined.
6-
const verifyIdeOpen = ({ fileName, action, hasPreferredIde, line, column }) => {
6+
const verifyIdeOpen = ({ fileName, filePath, action, hasPreferredIde, line, column }) => {
77
if (hasPreferredIde) {
88
cy.withCtx((ctx, o) => {
99
// @ts-expect-error - check if we've stubbed it already, only need to stub it once
@@ -15,8 +15,8 @@ const verifyIdeOpen = ({ fileName, action, hasPreferredIde, line, column }) => {
1515
action()
1616

1717
cy.withCtx((ctx, o) => {
18-
expect(ctx.actions.file.openFile).to.have.been.calledWith(o.sinon.match(new RegExp(`${o.fileName}$`)), o.line, o.column)
19-
}, { fileName, line, column })
18+
expect(ctx.actions.file.openFile).to.have.been.calledWith(o.sinon.match(new RegExp(`cypress/e2e/${o.filePath}$`)), o.line, o.column)
19+
}, { fileName, filePath, line, column })
2020
} else {
2121
action()
2222

@@ -38,6 +38,7 @@ const verifyFailure = (options) => {
3838
command,
3939
stack,
4040
fileName,
41+
filePath,
4142
uncaught = false,
4243
uncaughtMessage,
4344
line,
@@ -138,6 +139,7 @@ const verifyFailure = (options) => {
138139
if (verifyOpenInIde) {
139140
verifyIdeOpen({
140141
fileName,
142+
filePath,
141143
hasPreferredIde,
142144
action: () => {
143145
cy.get('@Root').contains('.runnable-err-stack-trace .runnable-err-file-path a', fileName)
@@ -185,6 +187,7 @@ const verifyFailure = (options) => {
185187
if (verifyOpenInIde) {
186188
verifyIdeOpen({
187189
fileName,
190+
filePath,
188191
hasPreferredIde,
189192
action: () => {
190193
cy.get('@Root').contains('.test-err-code-frame .runnable-err-file-path a', fileName)
@@ -198,12 +201,13 @@ const verifyFailure = (options) => {
198201

199202
type ChainableVerify = (specTitle: string, props: any) => Cypress.Chainable
200203

201-
export const createVerify = ({ fileName, hasPreferredIde, mode }): ChainableVerify => {
204+
export const createVerify = ({ fileName, filePath, hasPreferredIde, mode }): ChainableVerify => {
202205
return (specTitle: string, props: any) => {
203206
props.specTitle ||= specTitle
204207
props.fileName ||= fileName
205208
props.hasPreferredIde = hasPreferredIde
206209
props.mode = mode
210+
props.filePath ||= filePath
207211

208212
return cy.wrap(
209213
(props.verifyFn || verifyFailure).call(null, props),

0 commit comments

Comments
 (0)