Merge branch 'develop' into 9.0-release

This commit is contained in:
Emily Rohrbough
2021-10-28 09:32:27 -05:00
16 changed files with 289 additions and 56 deletions

32
.gitignore vendored
View File

@@ -13,18 +13,35 @@ cypress.zip
Cached Theme.pak
Cached Theme Material Design.pak
# from data-context, compiled .js files
packages/data-context/src/**/*.js
# from desktop-gui
packages/desktop-gui/cypress/videos
packages/desktop-gui/src/jsconfig.json
# from driver
packages/driver/cypress/videos
packages/driver/cypress/screenshots
# from launcher, compiled .js files
packages/launcher/index.js
packages/launcher/lib/**/*.js
# from network, compiled .js files
packages/network/lib/**/*.js
# from net-stubbing, compiled .js files
packages/net-stubbing/lib/**/*.js
# from runner
packages/runner/cypress/videos
packages/runner/cypress/screenshots
# from proxy, compiled .js files
packages/proxy/lib/**/*.js
# npm packages
npm/**/cypress/screenshots
@@ -33,6 +50,10 @@ packages/example/app
packages/example/build
packages/example/cypress/integration
# from frontend-shared
packages/frontend-shared/cypress/e2e/.projects
packages/frontend-shared/src/public/shiki/themes/cypress.theme.json
# from server
packages/server/.cy
packages/server/.projects
@@ -40,6 +61,9 @@ packages/server/support
packages/server/test/support/fixtures/server/imgs
packages/server/test/support/fixtures/server/libs
# from socket, dist built files
packages/socket/lib/*.js
# from system-tests
system-tests/.projects
system-tests/fixtures/large-img
@@ -57,6 +81,10 @@ system-tests/fixtures/large-img
# from runner-ct
/packages/runner-ct/cypress/screenshots
# graphql, auto-generated
/packages/launchpad/src/generated
/packages/app/src/generated
# from npm/create-cypress-tests
/npm/create-cypress-tests/initial-template
/npm/create-cypress-tests/src/test-output
@@ -343,3 +371,7 @@ $RECYCLE.BIN/
# Circle cache artifacts
globbed_node_modules
# Autogenerated files, typically from graphql-code-generator
*.gen.ts
*.gen.json

View File

@@ -5677,7 +5677,7 @@ declare namespace Cypress {
xhr: XMLHttpRequest
}
type Encodings = 'ascii' | 'base64' | 'binary' | 'hex' | 'latin1' | 'utf8' | 'utf-8' | 'ucs2' | 'ucs-2' | 'utf16le' | 'utf-16le'
type Encodings = 'ascii' | 'base64' | 'binary' | 'hex' | 'latin1' | 'utf8' | 'utf-8' | 'ucs2' | 'ucs-2' | 'utf16le' | 'utf-16le' | null
type PositionType = 'topLeft' | 'top' | 'topRight' | 'left' | 'center' | 'right' | 'bottomLeft' | 'bottom' | 'bottomRight'
type ViewportPreset = 'macbook-16' | 'macbook-15' | 'macbook-13' | 'macbook-11' | 'ipad-2' | 'ipad-mini' | 'iphone-xr' | 'iphone-x' | 'iphone-6+' | 'iphone-se2' | 'iphone-8' | 'iphone-7' | 'iphone-6' | 'iphone-5' | 'iphone-4' | 'iphone-3' | 'samsung-s10' | 'samsung-note9'
interface Offset {

View File

@@ -3,13 +3,21 @@ import type { Span } from 'next/dist/telemetry/trace/trace'
// Starting with v11.1.1, a trace is required.
// 'next/dist/telemetry/trace/trace' only exists since v10.0.9
// and our peerDeps support back to v8 so try-catch this import
// Starting from 12.0 trace is now located in 'next/dist/trace/trace'
export async function getRunWebpackSpan (): Promise<{ runWebpackSpan?: Span }> {
let trace: (name: string) => Span
try {
trace = await import('next/dist/telemetry/trace/trace').then((m) => m.trace)
try {
trace = await import('next/dist/telemetry/trace/trace').then((m) => m.trace)
return { runWebpackSpan: trace('cypress') }
return { runWebpackSpan: trace('cypress') }
} catch (_) {
// @ts-ignore
trace = await import('next/dist/trace/trace').then((m) => m.trace)
return { runWebpackSpan: trace('cypress') }
}
} catch (_) {
return {}
}

View File

@@ -37,6 +37,22 @@ describe('src/cy/commands/files', () => {
})
})
// https://github.com/cypress-io/cypress/issues/1558
it('passes explicit null encoding through to server and decodes response', () => {
Cypress.backend.resolves({
contents: Buffer.from('\n'),
filePath: '/path/to/foo.json',
})
cy.readFile('foo.json', null).then(() => {
expect(Cypress.backend).to.be.calledWith(
'read:file',
'foo.json',
{ encoding: null },
)
}).should('eql', Buffer.from('\n'))
})
it('sets the contents as the subject', () => {
Cypress.backend.resolves(okResponse)
@@ -340,6 +356,23 @@ describe('src/cy/commands/files', () => {
})
})
// https://github.com/cypress-io/cypress/issues/1558
it('explicit null encoding is sent to server as Buffer', () => {
Cypress.backend.resolves(okResponse)
cy.writeFile('foo.txt', Buffer.from([0, 0, 54, 255]), null).then(() => {
expect(Cypress.backend).to.be.calledWith(
'write:file',
'foo.txt',
Buffer.from([0, 0, 54, 255]),
{
encoding: null,
flag: 'w',
},
)
})
})
it('can take encoding as part of options', () => {
Cypress.backend.resolves(okResponse)

View File

@@ -35,6 +35,17 @@ describe('src/cy/commands/fixtures', () => {
})
})
// https://github.com/cypress-io/cypress/issues/1558
it('passes explicit null encoding through to server and decodes response', () => {
Cypress.backend.withArgs('get:fixture').resolves(Buffer.from('\n'))
cy.fixture('foo', null).then((obj) => {
expect(Cypress.backend).to.be.calledWith('get:fixture', 'foo', {
encoding: null,
})
}).should('eql', Buffer.from('\n'))
})
it('can have encoding as second argument and options as third argument', () => {
Cypress.backend.withArgs('get:fixture').resolves({ foo: 'bar' })

View File

@@ -11,11 +11,16 @@ export default (Commands, Cypress, cy) => {
if (_.isObject(encoding)) {
userOptions = encoding
encoding = null
encoding = undefined
}
options = _.defaults({}, userOptions, {
encoding: encoding != null ? encoding : 'utf8',
// https://github.com/cypress-io/cypress/issues/1558
// If no encoding is specified, then Cypress has historically defaulted
// to `utf8`, because of it's focus on text files. This is in contrast to
// NodeJs, which defaults to binary. We allow users to pass in `null`
// to restore the default node behavior.
encoding: encoding === undefined ? 'utf8' : encoding,
log: true,
})
@@ -53,6 +58,14 @@ export default (Commands, Cypress, cy) => {
args: { cmd: 'readFile', action: 'read', file, filePath: err.filePath, error: err.message },
})
}).then(({ contents, filePath }) => {
// https://github.com/cypress-io/cypress/issues/1558
// We invoke Buffer.from() in order to transform this from an ArrayBuffer -
// which socket.io uses to transfer the file over the websocket - into a
// `Buffer`, which webpack polyfills in the browser.
if (options.encoding === null) {
contents = Buffer.from(contents)
}
consoleProps['File Path'] = filePath
consoleProps['Contents'] = contents
@@ -85,11 +98,16 @@ export default (Commands, Cypress, cy) => {
if (_.isObject(encoding)) {
userOptions = encoding
encoding = null
encoding = undefined
}
options = _.defaults({}, userOptions, {
encoding: encoding ? encoding : 'utf8',
// https://github.com/cypress-io/cypress/issues/1558
// If no encoding is specified, then Cypress has historically defaulted
// to `utf8`, because of it's focus on text files. This is in contrast to
// NodeJs, which defaults to binary. We allow users to pass in `null`
// to restore the default node behavior.
encoding: encoding === undefined ? 'utf8' : encoding,
flag: userOptions.flag ? userOptions.flag : 'w',
log: true,
})
@@ -120,7 +138,7 @@ export default (Commands, Cypress, cy) => {
})
}
if (_.isObject(contents)) {
if (_.isObject(contents) && !Buffer.isBuffer(contents)) {
contents = JSON.stringify(contents, null, 2)
}

View File

@@ -6,6 +6,10 @@ import Promise from 'bluebird'
import $errUtils from '../../cypress/error_utils'
const clone = (obj) => {
if (Buffer.isBuffer(obj)) {
return Buffer.from(obj)
}
return JSON.parse(JSON.stringify(obj))
}
@@ -47,7 +51,7 @@ export default (Commands, Cypress, cy, state, config) => {
options = args[1]
}
if (_.isString(args[0])) {
if (_.isString(args[0]) || args[0] === null) {
options.encoding = args[0]
}
@@ -64,6 +68,18 @@ export default (Commands, Cypress, cy, state, config) => {
return $errUtils.throwErr(response.__error)
}
// https://github.com/cypress-io/cypress/issues/1558
// We invoke Buffer.from() in order to transform this from an ArrayBuffer -
// which socket.io uses to transfer the file over the websocket - into a
// `Buffer`, which webpack polyfills in the browser.
if (options.encoding === null) {
response = Buffer.from(response)
} else if (response instanceof ArrayBuffer) {
// Cypress' behavior is to base64 encode binary files if the user
// doesn't explicitly pass `null` as the encoding.
response = Buffer.from(response).toString('base64')
}
// add the fixture to the cache
// so it can just be returned next time
cache[fixture] = response

View File

@@ -1,8 +1,8 @@
# Electron
# @packages/electron
This is the lib responsible for installing + building Electron. This enables us to develop with the Electron shell that will match how the final compiled Cypress binary looks 1:1.
It does this by using `symlinks` while in development.
It does this by using symlinks while in development.
## Building
@@ -19,3 +19,33 @@ yarn workspace @packages/electron test
yarn workspace @packages/electron test-debug
yarn workspace @packages/electron test-watch
```
## Upgrading Electron
The version of `electron` that is bundled with Cypress should be kept as up-to-date as possible with the [stable Electron releases](https://www.electronjs.org/releases/stable). Many users expect the bundled Chromium and Node.js to be relatively recent. Also, historically, it has been extremely difficult to upgrade over multiple major versions of Electron at once, because of all the breaking changes in Electron and Node.js that impact Cypress.
Upgrading `electron` involves more than just bumping this package's `package.json`. Here are additional tasks to check off when upgrading Electron:
- [ ] **Write accurate changelog items.** The "User-facing changelog" for an Electron upgrade should mention the new Node.js and Chromium versions bundled.
- For example:
- Upgraded `electron` from `12.0.0-beta.14` to `13.1.7`.
- Upgraded bundled Node.js version from `14.6.0` to `14.17.0`.
- Upgraded bundled Chromium version from 89.0.0.1234 to 91.0.0.2345.
- [ ] **Determine if the Electron upgrade is a breaking change.** Electron upgrades constitute "breaking changes" in Cypress if:
- the major version number of Node.js changes, since users rely on the bundled Node.js to load plugins and `.js` fixtures, or
- there are changes to Electron that require new shared libraries to be installed on Linux, breaking existing CI setups, or
- there is some other change that would break existing usage of Cypress (for example, a Web API feature being removed/added to the bundled Chromium)
- [ ] **Create and publish Docker `base` and `browsers` family images matching the Node.js and Chromium versions in Electron.** The `browsers` image will be used for CI and the `base` will be used for any new `included` family images.
- See [`cypress-docker-images`](https://github.com/cypress-io/cypress-docker-images/).
- [ ] **Ensure that a matching Node.js version is enforced in the monorepo for local development and CI.** When Electron is upgraded, oftentimes, the bundled Node.js version that comes with Electron is updated as well. Because all unit and integration tests run in normal Node.js (not Electron's Node.js), it's important for this Node.js version to be synced with the monorepo. There are a few places where this needs to be done:
- [ ] [`/.node-version`](../../.node-version) - used by `nvm` and other Node version managers
- [ ] [`/appveyor.yml`](../../appveyor.yml) - update the `nodejs_version`
- [ ] [`/package.json`](../../package.json) - update `engines`
- [ ] [`/scripts/run-docker-local.sh`](../../scripts/run-docker-local.sh) - update Docker image to the new matching `browsers` image
- [ ] [`/circle.yml`](../../circle.yml)
- Update the Docker `image`s to the new matching `browsers` image.
- Update the `xcode` version to one with the same major Node.js version bundled. There is usually not an exact match, this is ok as long as the major version number as the same.
- [ ] Do a global search for the old Node.js version to identify any new areas that may need updating/unification, and update those locations (and this document!)
- [ ] **Manually smoke test `cypress open`.** Upgrading Electron can break the `desktop-gui` in unexpected ways. Since testing in this area is weak, double-check that things like launching `cypress open`, signing into the Dashboard, and launching Electron tests still work.
- [ ] **Fix failing tests.** Usually, these are due to breaking changes in either Node.js or Electron. Check the changelogs of both to find relevant changes.

View File

@@ -120,7 +120,7 @@ export async function setResponseFromFixture (getFixtureFn: GetFixtureFn, static
return
}
const data = await getFixtureFn(fixture.filePath, { encoding: fixture.encoding || null })
const data = await getFixtureFn(fixture.filePath, { encoding: fixture.encoding })
const { headers } = staticResponse

View File

@@ -20,8 +20,10 @@ interface Overrides {
const noop = () => {}
class FakeEventManager {
reporterBus: { on: () => void }
constructor (overrides: Overrides = {}) {
this.saveState = overrides.saveState || noop
this.reporterBus = { on: noop }
}
start = noop
@@ -132,4 +134,29 @@ describe('RunnerCt', () => {
cy.get(selectors.noSpecSelectedReporter).should('exist')
})
})
context('current spec is deleted', () => {
it('removes selection', () => {
const state = makeState({
spec: { relative: '/test.js', absolute: 'root/test.js', name: 'test.js' },
specs: [
{ relative: '/test2.js', absolute: 'root/test2.js', name: 'test2.js' },
{ relative: '/test.js', absolute: 'root/test.js', name: 'test.js' },
],
})
mount(<RunnerCt
state={state}
// @ts-ignore - this is difficult to stub. Real one breaks things.
eventManager={new FakeEventManager()}
config={fakeConfig}
/>)
cy.contains('Your tests are loading').then(() => {
state.setSpecs([{ relative: '/test2.js', absolute: 'root/test2.js', name: 'test2.js' }])
})
cy.contains('No spec selected')
})
})
})

View File

@@ -25,7 +25,19 @@ export abstract class BaseStore {
this.specRunId = nanoid()
}
@action checkCurrentSpecStillExists (specs: Cypress.Cypress['spec'][]) {
const newSpecsAbsolutes = new Set(specs.map((spec) => spec.absolute))
this.specs.forEach((oldSpec) => {
if (!newSpecsAbsolutes.has(oldSpec.absolute) && this.spec?.absolute === oldSpec.absolute) {
this.spec = undefined
}
})
}
@action setSpecs (specs: Cypress.Cypress['spec'][]) {
this.checkCurrentSpecStillExists(specs)
this.specs = specs
}

View File

@@ -4,9 +4,14 @@ const { fs } = require('./util/fs')
module.exports = {
readFile (projectRoot, file, options = {}) {
const filePath = path.resolve(projectRoot, file)
const readFn = path.extname(filePath) === '.json' ? fs.readJsonAsync : fs.readFileAsync
const readFn = (path.extname(filePath) === '.json' && options.encoding !== null) ? fs.readJsonAsync : fs.readFileAsync
return readFn(filePath, options.encoding || 'utf8')
// https://github.com/cypress-io/cypress/issues/1558
// If no encoding is specified, then Cypress has historically defaulted
// to `utf8`, because of it's focus on text files. This is in contrast to
// NodeJs, which defaults to binary. We allow users to pass in `null`
// to restore the default node behavior.
return readFn(filePath, options.encoding === undefined ? 'utf8' : options.encoding)
.then((contents) => {
return {
contents,
@@ -22,7 +27,7 @@ module.exports = {
writeFile (projectRoot, file, contents, options = {}) {
const filePath = path.resolve(projectRoot, file)
const writeOptions = {
encoding: options.encoding || 'utf8',
encoding: options.encoding === undefined ? 'utf8' : options.encoding,
flag: options.flag || 'w',
}

View File

@@ -1,4 +1,3 @@
const _ = require('lodash')
const path = require('path')
const check = require('syntax-error')
const debug = require('debug')('cypress:server:fixture')
@@ -116,15 +115,24 @@ module.exports = {
},
parseFileByExtension (p, fixture, ext, options = {}) {
// https://github.com/cypress-io/cypress/issues/1558
// If the user explicitly specifies `null` as the encoding, we treat the
// file as binary regardless of extension. We base64 encode them for
// transmission over the websocket. There is a matching Buffer.from()
// in packages/driver/src/cy/commands/fixtures.ts
if (options.encoding === null) {
return this.parse(p, fixture)
}
switch (ext) {
case '.json': return this.parseJson(p, fixture)
case '.js': return this.parseJs(p, fixture)
case '.coffee': return this.parseCoffee(p, fixture)
case '.html': return this.parseHtml(p, fixture)
case '.png': case '.jpg': case '.jpeg': case '.gif': case '.tif': case '.tiff': case '.zip':
return this.parse(p, fixture, _.isNull(options.encoding) ? null : (options.encoding || 'base64'))
return this.parse(p, fixture, options.encoding)
default:
return this.parse(p, fixture, _.isNull(options.encoding) ? null : options.encoding)
return this.parse(p, fixture, options.encoding || 'utf8')
}
},
@@ -184,7 +192,7 @@ module.exports = {
.bind(this)
},
parse (p, fixture, encoding = 'utf8') {
parse (p, fixture, encoding) {
return fs.readFileAsync(p, encoding)
.bind(this)
},

View File

@@ -41,6 +41,13 @@ describe('lib/files', () => {
})
})
// https://github.com/cypress-io/cypress/issues/1558
it('explicit null encoding is sent to driver as a Buffer', function () {
return files.readFile(this.projectRoot, 'tests/_fixtures/ascii.foo', { encoding: null }).then(({ contents }) => {
expect(contents).to.eql(Buffer.from('\n'))
})
})
it('parses json to valid JS object', function () {
return files.readFile(this.projectRoot, 'tests/_fixtures/users.json').then(({ contents }) => {
expect(contents).to.eql([
@@ -75,6 +82,15 @@ describe('lib/files', () => {
})
})
// https://github.com/cypress-io/cypress/issues/1558
it('explicit null encoding is written exactly as received', function () {
return files.writeFile(this.projectRoot, '.projects/write_file.txt', Buffer.from(''), { encoding: null }).then(() => {
return files.readFile(this.projectRoot, '.projects/write_file.txt', { encoding: null }).then(({ contents }) => {
expect(contents).to.eql(Buffer.from(''))
})
})
})
it('overwrites existing file by default', function () {
return files.writeFile(this.projectRoot, '.projects/write_file.txt', 'foo').then(() => {
return files.readFile(this.projectRoot, '.projects/write_file.txt').then(({ contents }) => {

View File

@@ -18,6 +18,9 @@ describe('lib/fixture', () => {
FixturesHelper.scaffold()
this.todosPath = FixturesHelper.projectPath('todos')
this.read = (folder, image, encoding) => {
return fs.readFileAsync(path.join(folder, image), encoding)
}
return config.get(this.todosPath).then((cfg) => {
({ fixturesFolder: this.fixturesFolder } = cfg)
@@ -172,8 +175,8 @@ Expecting 'EOF', '}', ':', ',', ']', got 'STRING'\
return config.get(projectPath)
.then((cfg) => {
return fixture.get(cfg.fixturesFolder, 'foo')
.then((fixture) => {
expect(fixture).to.deep.eq({ 'bar': 'baz' })
.then((result) => {
expect(result).to.deep.eq({ 'bar': 'baz' })
})
})
})
@@ -325,6 +328,15 @@ John,Chef,1982
})
})
// https://github.com/cypress-io/cypress/issues/1558
context('binary files', () => {
it('returns file as buffer regardless of extension when passed null encoding', function () {
return fixture.get(this.fixturesFolder, 'nested/fixture.js', { encoding: null }).then((index) => {
expect(index).to.eql(Buffer.from('{nested: "fixture"}'))
})
})
})
context('file with unknown extension and encoding specified', () => {
it('returns text encoded as specified', function () {
return fixture.get(this.fixturesFolder, 'ascii.foo', { encoding: 'ascii' }).then((index) => {
@@ -334,69 +346,64 @@ John,Chef,1982
})
context('image files', () => {
beforeEach(function () {
this.read = (folder, image, encoding) => {
return fs.readFileAsync(path.join(folder, image), encoding)
}
})
it('returns png as string', function () {
return this.read(this.fixturesFolder, 'images/flower.png', 'base64')
.then((str) => {
it('returns png as buffer', function () {
return this.read(this.fixturesFolder, 'images/flower.png')
.then((file) => {
return fixture.get(this.fixturesFolder, 'images/flower.png')
.then((base64) => {
expect(base64).to.eq(str)
.then((result) => {
expect(result).to.eql(file)
})
})
})
it('returns jpg as string', function () {
return this.read(this.fixturesFolder, 'images/sample.jpg', 'base64')
.then((str) => {
it('returns jpg as buffer', function () {
return this.read(this.fixturesFolder, 'images/sample.jpg')
.then((file) => {
return fixture.get(this.fixturesFolder, 'images/sample.jpg')
.then((base64) => {
expect(base64).to.eq(str)
.then((result) => {
expect(result).to.eql(file)
})
})
})
it('returns gif as string', function () {
return this.read(this.fixturesFolder, 'images/word.gif', 'base64')
.then((str) => {
it('returns gif as buffer', function () {
return this.read(this.fixturesFolder, 'images/word.gif')
.then((file) => {
return fixture.get(this.fixturesFolder, 'images/word.gif')
.then((base64) => {
expect(base64).to.eq(str)
.then((result) => {
expect(result).to.eql(file)
})
})
})
it('returns tif as string', function () {
return this.read(this.fixturesFolder, 'images/sample.tif', 'base64')
.then((str) => {
it('returns tif as buffer', function () {
return this.read(this.fixturesFolder, 'images/sample.tif')
.then((file) => {
return fixture.get(this.fixturesFolder, 'images/sample.tif')
.then((base64) => {
expect(base64).to.eq(str)
.then((result) => {
expect(result).to.eql(file)
})
})
})
it('returns png as binary', function () {
it('returns png as binary if that encoding is requested', function () {
return this.read(this.fixturesFolder, 'images/flower.png', 'binary')
.then((bin) => {
.then((file) => {
return fixture.get(this.fixturesFolder, 'images/flower.png', { encoding: 'binary' })
.then((bin2) => {
expect(bin).to.eq(bin2)
.then((result) => {
expect(result).to.eq(file)
})
})
})
})
context('zip files', () => {
it('returns zip as base64 string', function () {
return fixture.get(this.fixturesFolder, 'example.zip').then((base64) => {
const str = 'UEsDBAoAAAAAAK2zOUcAAAAAAAAAAAAAAAAEABAAemlwL1VYDAAGAwZWBgMGVvUBFABQSwMECgAAAAAAo7M5RwAAAAAAAAAAAAAAAAkAEAB6aXAvYS50eHRVWAwA8QIGVvECBlb1ARQAUEsDBAoAAAAAAKSzOUcAAAAAAAAAAAAAAAAJABAAemlwL2IudHh0VVgMAPMCBlbzAgZW9QEUAFBLAwQKAAAAAAClszlHAAAAAAAAAAAAAAAACQAQAHppcC9jLnR4dFVYDAD1AgZW9QIGVvUBFABQSwMECgAAAAAApbM5RwAAAAAAAAAAAAAAAAkAEAB6aXAvZC50eHRVWAwA9gIGVvYCBlb1ARQAUEsDBAoAAAAAAKazOUcAAAAAAAAAAAAAAAAJABAAemlwL2UudHh0VVgMAPgCBlb4AgZW9QEUAFBLAwQKAAAAAACnszlHAAAAAAAAAAAAAAAACQAQAHppcC9mLnR4dFVYDAD5AgZW+QIGVvUBFABQSwMECgAAAAAAqLM5RwAAAAAAAAAAAAAAAAkAEAB6aXAvZy50eHRVWAwA+wIGVvsCBlb1ARQAUEsDBAoAAAAAAKizOUcAAAAAAAAAAAAAAAAJABAAemlwL2gudHh0VVgMAPwCBlb8AgZW9QEUAFBLAwQKAAAAAACpszlHAAAAAAAAAAAAAAAACQAQAHppcC9pLnR4dFVYDAD9AgZW/QIGVvUBFABQSwMECgAAAAAAqrM5RwAAAAAAAAAAAAAAAAkAEAB6aXAvai50eHRVWAwA/wIGVv8CBlb1ARQAUEsDBAoAAAAAAK2zOUcAAAAAAAAAAAAAAAAJABAAemlwL2sudHh0VVgMAAYDBlYGAwZW9QEUAFBLAQIVAwoAAAAAAK2zOUcAAAAAAAAAAAAAAAAEAAwAAAAAAAAAAEDtQQAAAAB6aXAvVVgIAAYDBlYGAwZWUEsBAhUDCgAAAAAAo7M5RwAAAAAAAAAAAAAAAAkADAAAAAAAAAAAQKSBMgAAAHppcC9hLnR4dFVYCADxAgZW8QIGVlBLAQIVAwoAAAAAAKSzOUcAAAAAAAAAAAAAAAAJAAwAAAAAAAAAAECkgWkAAAB6aXAvYi50eHRVWAgA8wIGVvMCBlZQSwECFQMKAAAAAAClszlHAAAAAAAAAAAAAAAACQAMAAAAAAAAAABApIGgAAAAemlwL2MudHh0VVgIAPUCBlb1AgZWUEsBAhUDCgAAAAAApbM5RwAAAAAAAAAAAAAAAAkADAAAAAAAAAAAQKSB1wAAAHppcC9kLnR4dFVYCAD2AgZW9gIGVlBLAQIVAwoAAAAAAKazOUcAAAAAAAAAAAAAAAAJAAwAAAAAAAAAAECkgQ4BAAB6aXAvZS50eHRVWAgA+AIGVvgCBlZQSwECFQMKAAAAAACnszlHAAAAAAAAAAAAAAAACQAMAAAAAAAAAABApIFFAQAAemlwL2YudHh0VVgIAPkCBlb5AgZWUEsBAhUDCgAAAAAAqLM5RwAAAAAAAAAAAAAAAAkADAAAAAAAAAAAQKSBfAEAAHppcC9nLnR4dFVYCAD7AgZW+wIGVlBLAQIVAwoAAAAAAKizOUcAAAAAAAAAAAAAAAAJAAwAAAAAAAAAAECkgbMBAAB6aXAvaC50eHRVWAgA/AIGVvwCBlZQSwECFQMKAAAAAACpszlHAAAAAAAAAAAAAAAACQAMAAAAAAAAAABApIHqAQAAemlwL2kudHh0VVgIAP0CBlb9AgZWUEsBAhUDCgAAAAAAqrM5RwAAAAAAAAAAAAAAAAkADAAAAAAAAAAAQKSBIQIAAHppcC9qLnR4dFVYCAD/AgZW/wIGVlBLAQIVAwoAAAAAAK2zOUcAAAAAAAAAAAAAAAAJAAwAAAAAAAAAAECkgVgCAAB6aXAvay50eHRVWAgABgMGVgYDBlZQSwUGAAAAAAwADAAfAwAAjwIAAAAA'
expect(base64).to.eq(str)
it('returns zip as buffer', function () {
return this.read(this.fixturesFolder, 'example.zip')
.then((file) => {
return fixture.get(this.fixturesFolder, 'example.zip').then((result) => {
expect(result).to.eql(file)
})
})
})
})

View File

@@ -456,6 +456,16 @@ describe('lib/socket', () => {
return this.client.emit('backend:request', 'get:fixture', 'does-not-exist.txt', {}, cb)
})
it('passes Buffers through intact', function (done) {
const cb = function (resp) {
expect(resp.response).to.eql(Buffer.from('[{"json": true}]'))
return done()
}
return this.client.emit('backend:request', 'get:fixture', 'foo', { encoding: null }, cb)
})
})
context('on(http:request)', () => {