Skip to content

Commit ce8f0ee

Browse files
lilaconleechrisbreiding
authored andcommitted
Yield null from cy.writeFile (#2731)
- Fixes #2466 - [Docs PR](cypress-io/cypress-documentation#1117) Should be part of 4.0.0
1 parent 59ab85b commit ce8f0ee

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,13 @@ module.exports = (Commands, Cypress, cy, state, config) ->
9494
})
9595

9696
if _.isObject(contents)
97-
objContents = contents
9897
contents = JSON.stringify(contents, null, 2)
9998

10099
Cypress.backend("write:file", fileName, contents, _.pick(options, ["encoding", "flag"]))
101100
.then ({ contents, filePath }) ->
102101
consoleProps["File Path"] = filePath
103102
consoleProps["Contents"] = contents
104-
if objContents?
105-
return objContents
106-
return contents
103+
return null
107104
.catch Promise.TimeoutError, (err) ->
108105
$utils.throwErrByPath "files.timed_out", {
109106
onFail: options._log

packages/driver/test/cypress/integration/commands/files_spec.coffee

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -286,17 +286,11 @@ describe "src/cy/commands/files", ->
286286
}
287287
)
288288

289-
it "sets the contents as the subject", ->
289+
it "yields null", ->
290290
Cypress.backend.resolves(okResponse)
291291

292292
cy.writeFile("foo.txt", "contents").then (subject) ->
293-
expect(subject).to.equal("contents")
294-
295-
it "sets a JSON as the subject", ->
296-
Cypress.backend.resolves(okResponse)
297-
298-
cy.writeFile("foo.json", { name: "Test" }).then (subject) ->
299-
expect(subject.name).to.equal("Test")
293+
expect(subject).to.not.exist
300294

301295
it "can write a string", ->
302296
Cypress.backend.resolves(okResponse)

0 commit comments

Comments
 (0)