Skip to content

Commit f2a381c

Browse files
Merge branch 'develop' into release/15.0.0
2 parents 1e7d456 + 5fde494 commit f2a381c

File tree

6 files changed

+59
-22
lines changed

6 files changed

+59
-22
lines changed

.circleci/workflows.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3064,6 +3064,9 @@ linux-x64-workflow: &linux-x64-workflow
30643064
- npm-mount-utils:
30653065
requires:
30663066
- build
3067+
- npm-grep:
3068+
requires:
3069+
- build
30673070
- npm-eslint-plugin-dev:
30683071
requires:
30693072
- build
@@ -3084,6 +3087,7 @@ linux-x64-workflow: &linux-x64-workflow
30843087
- npm-puppeteer-cypress-tests
30853088
- npm-react
30863089
- npm-mount-utils
3090+
- npm-grep
30873091
- npm-vue
30883092
- npm-webpack-batteries-included-preprocessor
30893093
- npm-webpack-preprocessor
@@ -3461,6 +3465,9 @@ linux-x64-contributor-workflow: &linux-x64-contributor-workflow
34613465
- npm-mount-utils:
34623466
requires:
34633467
- build
3468+
- npm-grep:
3469+
requires:
3470+
- build
34643471
- npm-eslint-plugin-dev:
34653472
requires:
34663473
- build
@@ -3480,6 +3487,7 @@ linux-x64-contributor-workflow: &linux-x64-contributor-workflow
34803487
- npm-puppeteer-cypress-tests
34813488
- npm-react
34823489
- npm-mount-utils
3490+
- npm-grep
34833491
- npm-vue
34843492
- npm-webpack-batteries-included-preprocessor
34853493
- npm-webpack-preprocessor

cli/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ _Released 07/29/2025 (PENDING)_
3333
- Fixed an issue where `isSecureContext` would be `false` on localhost when testing with Cypress. Addresses [#18217](https://github.com/cypress-io/cypress/issues/18217).
3434
- Fixed an issue where Angular legacy `Output()` decorators were broken when making component instance field references safe. Fixes [#32137](https://github.com/cypress-io/cypress/issues/32137).
3535
- Upgraded `tmp` from `~0.2.3` to `~0.2.4`. This removes the [CVE-2025-54798](https://github.com/advisories/GHSA-52f5-9888-hmc6) vulnerability being reported in security scans. Addresses [#32176](https://github.com/cypress-io/cypress/issues/32176).
36+
- Fixed an issue where `.fixture()` calls with a specified encoding would sometimes still attempt to parse the file based on its extension. Files with an explicit encoding are now always treated as raw content. Fixes [#32139](https://github.com/cypress-io/cypress/issues/32139).
37+
- Fixed an issue where `.fixture()` calls with different encoding options would return inconsistent content based on execution order. Fixes [#32138](https://github.com/cypress-io/cypress/issues/32138).
3638

3739
**Misc:**
3840

packages/driver/cypress/e2e/commands/fixtures.cy.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,26 @@ describe('src/cy/commands/fixtures', () => {
265265
})
266266
})
267267
})
268+
269+
it('should respect encoding specification', () => {
270+
const fixture = 'comma-separated.csv'
271+
272+
cy.fixture(fixture, 'base64').then((content) => {
273+
cy.wrap(content).should('eq', 'T25lLFR3byxUaHJlZQoxLDIsMwo=')
274+
cy.wrap(content).as('base64')
275+
})
276+
277+
cy.fixture(fixture).then((content) => {
278+
cy.wrap(content).should('eq', 'One,Two,Three\n1,2,3\n')
279+
cy.wrap(content).as('utf8')
280+
})
281+
282+
cy.get('@base64').then((base64) => {
283+
cy.get('@utf8').then((utf8) => {
284+
cy.wrap(base64).should('not.eq', utf8)
285+
})
286+
})
287+
})
268288
})
269289
})
270290
})

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

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,6 @@ export default (Commands, Cypress, cy, state, config) => {
2828
$errUtils.throwErrByPath('fixture.set_to_false')
2929
}
3030

31-
// if we already have cached
32-
// this fixture then just return it
33-
34-
// always return a promise here
35-
// to make our interface consistent
36-
// for use by other code
37-
const resp = cache[fixture]
38-
39-
if (resp) {
40-
// clone the object first to prevent
41-
// accidentally mutating the one in the cache
42-
return Promise.resolve(clone(resp))
43-
}
44-
4531
let options: Record<string, any> = {}
4632

4733
if (_.isObject(args[0])) {
@@ -54,6 +40,14 @@ export default (Commands, Cypress, cy, state, config) => {
5440
options.encoding = args[0]
5541
}
5642

43+
const cacheKey = `${fixture}\u0000${options.encoding || ''}`
44+
const cachedContent = cache[cacheKey]
45+
46+
if (cachedContent) {
47+
// Clone the cached content to prevent accidental mutation.
48+
return Promise.resolve(clone(cachedContent))
49+
}
50+
5751
const timeout = options.timeout ?? Cypress.config('responseTimeout')
5852

5953
// need to remove the current timeout
@@ -81,7 +75,7 @@ export default (Commands, Cypress, cy, state, config) => {
8175

8276
// add the fixture to the cache
8377
// so it can just be returned next time
84-
cache[fixture] = response
78+
cache[cacheKey] = response
8579

8680
// Add the filename as a symbol, in case we need it later (such as when storing an alias)
8781
state('current').set('fileName', basename(fixture))

packages/server/lib/fixture.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,10 @@ module.exports = {
125125
},
126126

127127
parseFileByExtension (p, fixture, ext, options = {}) {
128-
// https://github.com/cypress-io/cypress/issues/1558
129-
// If the user explicitly specifies `null` as the encoding, we treat the
130-
// file as binary regardless of extension. We base64 encode them for
131-
// transmission over the websocket. There is a matching Buffer.from()
132-
// in packages/driver/src/cy/commands/fixtures.ts
133-
if (options.encoding === null) {
134-
return this.parse(p, fixture)
128+
// If an encoding is specified, return the raw file content instead of
129+
// parsing.
130+
if (typeof options.encoding !== 'undefined') {
131+
return this.parse(p, fixture, options.encoding)
135132
}
136133

137134
switch (ext) {

packages/server/test/unit/fixture_spec.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,22 @@ describe('lib/fixture', () => {
167167
})
168168
})
169169
})
170+
171+
it('should return encoded JSON', async function () {
172+
const fixtures = [
173+
{ encoding: '', content: Buffer.from('[{"json": true}]') },
174+
{ encoding: 'base64', content: 'W3sianNvbiI6IHRydWV9XQ==' },
175+
{ encoding: 'utf8', content: '[{"json": true}]' },
176+
{ encoding: null, content: Buffer.from('[{"json": true}]') },
177+
{ encoding: undefined, content: [{ json: true }] },
178+
]
179+
180+
for (const { encoding, content } of fixtures) {
181+
const result = await fixture.get(this.fixturesFolder, 'foo', { encoding })
182+
183+
expect(result).to.deep.equal(content)
184+
}
185+
})
170186
})
171187

172188
context('js files', () => {

0 commit comments

Comments
 (0)