mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-22 23:20:24 -05:00
9147e4f988
* add e2e test for submitting forms over https on localhost * add multipart/form-data test * add multiparty to parse multipart/form-data streams * test form submission with attachments * add repro for #4253 * stream_buffer failing on large body size * wip: stream buffer fixes * add eslint + require spec helper * always cleanup on error and on response * WIP: continue refactoring stream buffer - utilize ‘finish’ and ‘chunk’ events to know when to push into internal readable buffer instead of using `readable.push(‘’)` - recursively call readable.push(…) until it returns false - add tests for recursive push calls - add tests for ensuring readables don’t end until writeable buffer does * fix remaining tests after stream buffer refactor * use path.resolve not path.join for handling cy.readFile + cy.writeFile * consolidate e2e form multipart tests with existing ones - use env var for passing around path to large earth image - dynamically fetch large earth.jpg img and gitignore it prior to running tests - finish tests + passing implementation * reader() -> createReadStream() * guard against reqBodyBuffer being null Co-authored-by: Brian Mann <brian.mann86@gmail.com>
39 lines
931 B
CoffeeScript
39 lines
931 B
CoffeeScript
path = require("path")
|
|
Promise = require("bluebird")
|
|
fs = require("./util/fs")
|
|
|
|
module.exports = {
|
|
readFile: (projectRoot, file, options = {}) ->
|
|
filePath = path.resolve(projectRoot, file)
|
|
readFn = if path.extname(filePath) is ".json"
|
|
fs.readJsonAsync
|
|
else
|
|
fs.readFileAsync
|
|
|
|
readFn(filePath, options.encoding or "utf8")
|
|
.then (contents) ->
|
|
{
|
|
contents: contents
|
|
filePath: filePath
|
|
}
|
|
.catch (err) ->
|
|
err.filePath = filePath
|
|
throw err
|
|
|
|
writeFile: (projectRoot, file, contents, options = {}) ->
|
|
filePath = path.resolve(projectRoot, file)
|
|
writeOptions = {
|
|
encoding: options.encoding or "utf8"
|
|
flag: options.flag or "w"
|
|
}
|
|
fs.outputFile(filePath, contents, writeOptions)
|
|
.then ->
|
|
{
|
|
contents: contents
|
|
filePath: filePath
|
|
}
|
|
.catch (err) ->
|
|
err.filePath = filePath
|
|
throw err
|
|
}
|