From ce8f0ee84f01c2f50fe166f642d5e7720b49d864 Mon Sep 17 00:00:00 2001 From: Lila Conlee Date: Mon, 3 Dec 2018 14:33:36 -0500 Subject: [PATCH] Yield null from cy.writeFile (#2731) - Fixes #2466 - [Docs PR](https://github.com/cypress-io/cypress-documentation/pull/1117) Should be part of 4.0.0 --- packages/driver/src/cy/commands/files.coffee | 5 +---- .../cypress/integration/commands/files_spec.coffee | 10 ++-------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/packages/driver/src/cy/commands/files.coffee b/packages/driver/src/cy/commands/files.coffee index 6578adbc4d88..40f7a3009f07 100644 --- a/packages/driver/src/cy/commands/files.coffee +++ b/packages/driver/src/cy/commands/files.coffee @@ -94,16 +94,13 @@ module.exports = (Commands, Cypress, cy, state, config) -> }) if _.isObject(contents) - objContents = contents contents = JSON.stringify(contents, null, 2) Cypress.backend("write:file", fileName, contents, _.pick(options, ["encoding", "flag"])) .then ({ contents, filePath }) -> consoleProps["File Path"] = filePath consoleProps["Contents"] = contents - if objContents? - return objContents - return contents + return null .catch Promise.TimeoutError, (err) -> $utils.throwErrByPath "files.timed_out", { onFail: options._log diff --git a/packages/driver/test/cypress/integration/commands/files_spec.coffee b/packages/driver/test/cypress/integration/commands/files_spec.coffee index b767fbcb5369..b23d0bf22d54 100644 --- a/packages/driver/test/cypress/integration/commands/files_spec.coffee +++ b/packages/driver/test/cypress/integration/commands/files_spec.coffee @@ -286,17 +286,11 @@ describe "src/cy/commands/files", -> } ) - it "sets the contents as the subject", -> + it "yields null", -> Cypress.backend.resolves(okResponse) cy.writeFile("foo.txt", "contents").then (subject) -> - expect(subject).to.equal("contents") - - it "sets a JSON as the subject", -> - Cypress.backend.resolves(okResponse) - - cy.writeFile("foo.json", { name: "Test" }).then (subject) -> - expect(subject.name).to.equal("Test") + expect(subject).to.not.exist it "can write a string", -> Cypress.backend.resolves(okResponse)