Commit Graph

77 Commits

Author SHA1 Message Date
Lachlan Miller
ddaa21478d simplify object passed to createRoutes 2021-07-21 12:36:04 +10:00
Lachlan Miller
8d13188730 only pass necessary values to createRoutes 2021-07-21 12:01:58 +10:00
Tim Griesser
e3a5bdf111 refactor: add @packages/resolve-dist to isolate client/server code (#17109) 2021-06-29 12:54:29 -04:00
Lachlan Miller
8e11b2d3b2 chore(server,server-ct): share initPlugins and spec watcher via Server Base class #16974 (#16981)
* move specs store to server

* customize spec directory in store

* share plugins via project base

* shared updated config

* share spec finding logic

* fix test

* share spec store code

* remove comment

* try fixing test

* move code around

* move more code

* share sendSpecList

* comment out line

* comments

* logs

* stub chokidar

* remove stub

* move spec watcher to later in the lifecycle

* refactor watcher

* stub out chikidar

* remove old code

* refactor

* update server-ct

* fix implementation

* fix implementation

* fix test

* update types

* add back check for config

* add comment

* make server base abstract

* fix type

* export interface

* move routes to TS

* update types

* types

* fix types

* correctly pass specs store in test

Co-authored-by: Barthélémy Ledoux <bart@cypress.io>
2021-06-23 10:35:12 +10:00
Jessica Sachs
3b69ccc283 break: removing the experimentalCypressComponentTesting flag 2021-03-29 15:29:59 -04:00
Adam Gastineau
2ce77aaa74 Fixed componentTestingEnabled vars 2021-03-29 11:45:49 -07:00
Adam Gastineau
fa780634ca Removed experimentalComponentTesting flag 2021-03-29 10:47:52 -07:00
Brian Mann
af26fbebe6 feat: component testing (#14479)
Co-authored-by: Jessica Sachs <jess@jessicasachs.io>
Co-authored-by: Barthélémy Ledoux <bart@cypress.io>
Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com>
Co-authored-by: Zach Bloomquist <github@chary.us>
Co-authored-by: Dmitriy Kovalenko <dmtr.kovalenko@outlook.com>
Co-authored-by: ElevateBart <ledouxb@gmail.com>
Co-authored-by: Ben Kucera <14625260+Bkucera@users.noreply.github.com>
2021-02-04 15:45:16 -05:00
Mo
dae76a8ec0 fix: XHR stub error if response json has number/boolean (#9107)
Co-authored-by: Jennifer Shehane <jennifer@cypress.io>
2020-11-09 13:14:07 +06:30
Gleb Bahmutov
5610f4dbe9 feat: working on running all component tests together (#8703)
Co-authored-by: Jennifer Shehane <jennifer@cypress.io>
2020-11-03 09:15:27 -05:00
Chris Breiding
3a16e23bc6 fix: Fix crashing due to rerunning on initial bundle of specs (#8264)
* ignore sendFile EPIPE errors

* upgrade @cypress/webpack-preprocessor to 5.4.4
2020-08-12 14:45:39 -04:00
Gleb Bahmutov
fe96d7cf2a feat: run only filtered specs (#8007)
Co-authored-by: Jennifer Shehane <jennifer@cypress.io>
2020-07-30 10:29:21 -04:00
Zach Bloomquist
fe785749e8 server decaf cleanup
cleanup
2020-06-04 14:48:33 -04:00
decaffeinate
e7d1f313b0 decaffeinate: Run post-processing cleanups on api.coffee and 35 other files
decaffeinate: Run post-processing cleanups on reporter.coffee
2020-06-04 14:03:03 -04:00
decaffeinate
0f035b976c decaffeinate: Convert api.coffee and 35 other files to JS
decaffeinate: Convert reporter.coffee to JS
2020-06-04 14:03:01 -04:00
decaffeinate
c7dd989893 decaffeinate: Rename api.coffee and 35 other files from .coffee to .js
decaffeinate: Rename reporter.coffee from .coffee to .js
2020-06-04 14:02:58 -04:00
Gleb Bahmutov
d284269daa watch spec file without assuming it is integration spec (#7247) 2020-05-08 11:43:27 -04:00
Jennifer Shehane
a27bd34df3 Reporter error improvements (#3930) 2020-05-06 12:18:29 -04:00
Chris Breiding
c6fee8f259 Fix 'onError is not function' bug (#7230) 2020-05-05 16:19:17 -04:00
Dmitriy Kovalenko
379a9e7008 feat: improve component based tests approach (#5923)
- new mode that mounts the spec iframe instead of application iframe
2020-04-26 16:25:24 -04:00
Zach Bloomquist
47410d50e5 Fix "Parse Error" when performing HTTP requests (#5988)
* Detect if NODE_OPTIONS are present in binary; if not, respawn

* Always reset NODE_OPTIONS, even if no ORIGINAL_

Co-authored-by: Andrew Smith <andrew@andrew.codes>

* Exit with correct code # from stub process

* Clean up based on Brian's feedback

* how process.versions is null, i have no idea, but it is

* add repro for invalid header char

* Always pass NODE_OPTIONS with max-http-header-size (#5452)

* cli: set NODE_OPTIONS=--max-http-header-size=1024*1024 on spawn

* electron: remove redundant max-http-header-size

* server: add useCli option to make e2e tests go thru cli

* server: add test for XHR with body > 100kb via CLI

* clean up conditional

* cli: don't pass --max-http-header-size in dev w node < 11.10

* add original_node_options to restore o.g. user node_options

* force no color

* Revert "Use websockets to stub large XHR response bodies instead of hea… (#5525)"

This reverts commit 249db45363.

* fix yarn.lock

* update 4_xhr_spec snapshot

* make 6_visit_spec reproduce invalid header char error

* pass --http-parser=legacy

* still set headers if an ERR_INVALID_CHAR is raised

* add --http-parser=legacy in some more places

* update http_requests_spec

* readd spawn_spec

* improve debug logging

* remove unnecessary changes

* cleanup

* revert yarn.lock to develop

* use cp.spawn, not cp.fork

to work around the Electron patch: 39baf68790/patches/node/refactor_alter_child_process_fork_to_use_execute_script_with.patch

Co-authored-by: Andrew Smith <andrew@andrew.codes>
2020-03-18 17:26:22 -04:00
renovate[bot]
280594a5e7 fix(deps): Update dependency mime to version .x 🌟 (#6764)
* fix(deps): Update mime to 2.4.4 🌟

* update method names from 2.0 breaking changes

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Jennifer Shehane <jennifer@cypress.io>
2020-03-18 13:15:08 +06:30
Chris Breiding
edb9a98268 Allow %, &, and ? in spec file name. (#6539)
* Allow %, & in file name.

* Extract escapeFilenameInUrl

* Fix tests.

* Add test for ? (non-Windows).

* Remove platform condition. And handle when special chars are in the dir.

* Fix failure.

* Fix failure.

* add e2e test for specs with special characters

* minor refactor

Co-authored-by: Chris Breiding <chrisbreiding@users.noreply.github.com>
2020-03-05 12:21:29 -05:00
Chris Breiding
474b80a50f Fix race condition when there's an early asynchronous error in… (#6610)
* fix race condition when there's an async error in root of plugins file

* return the promise

* fix routes creation

* fix tests

* fix error throwing and add tests

* update snapshots

* revert changes to server.open signatures in tests

* fix test

* properly wrap error so it doesn't log twice

* slow down test to ensure plugins error occurs before run is over

* wait to log early exit error until after run start
2020-03-04 11:59:01 -05:00
Chris Breiding
1e7f0c1fdf remove unnecessary returns 2020-02-28 11:46:27 -05:00
decaffeinate
ce1aa3f799 decaffeinate: Run post-processing cleanups on spec.coffee 2020-02-28 11:39:13 -05:00
decaffeinate
1d9da41671 decaffeinate: Convert spec.coffee to JS 2020-02-28 11:38:38 -05:00
decaffeinate
1aafa23425 decaffeinate: Rename spec.coffee from .coffee to .js 2020-02-28 11:38:11 -05:00
Zach Bloomquist
15c3e95429 Improve error experience when visiting outside of Cypress-launched browser (#6435)
* force websockets transport

* wip: ensure ws connections take place thru a known socket

* clean up yesterday's work

* remove dead code (request is undefined)

* update websocket tests

* add websocket tests

* update socket + server specs

* add token auth for file_server

* Fix cy.visit file_server

* restrict non-proxied URLs, serve error on runner URL non-proxied

* add e2e test for server splash page

* fix types

* use clientRoute, fix tests

* only run 6_non_proxied in electron

* use browser.path

* improve empty options type

* add ws assertions in e2e tests

* fix server_spec

* refactor socket whitelisting logic

* update server_spec

* respond to PR feedback

- added tests for non-clientRoute redirecting to clientRoute when not behind proxy
- cleaned up comments
- cleaned up logic in server.coffee
- moved error html to own file
- added unit test for socket whitelist + fixed removal bug
2020-02-14 16:21:36 -05:00
Chris Breiding
d76123b3d9 Add Firefox support (#1359)
Co-authored-by: Ben Kucera <14625260+Bkucera@users.noreply.github.com>
Co-authored-by: Gleb Bahmutov <gleb.bahmutov@gmail.com>
Co-authored-by: Brian Mann <brian.mann86@gmail.com>
Co-authored-by: Zach Bloomquist <github@chary.us>
Co-authored-by: Jennifer Shehane <shehane.jennifer@gmail.com>
2020-02-06 10:52:13 -05:00
Zach Bloomquist
b0378dc04e Refactor proxy into own package, implement middleware pattern (#5136)
* renames

* Refactor proxy into own package, implement middleware pattern

don't need these mocha opts anymore

fix test

no more zunder

READMEs

fix test

* pass request by reference

* fix cors path

* Move replace_stream to proxy, concat-stream util in network

* Pin dependency versions

* Revert addDefaultPort behavior

* Add READMEs for proxy, network

* Update README.md

* eslint --fix

* set to null not undefined

* use delete and bump node types

* import cors from package now

* parse-domain@2.3.4

* proxy package needs common-tags

* move pumpify dep

* load through where it's needed, remove unused passthru_stream

* remove unneeded getbuffer call


Co-authored-by: Gleb Bahmutov <gleb.bahmutov@gmail.com>
2019-11-27 19:16:15 -05:00
Kukhyeon Heo
26ed04b637 Fixed null JSON file error. (#5562)
* Fixed null JSON file error.

* Added new fixture page to fix the failure.

* [] -> ''.

* Fixed test message.

* Asserts returned json value on the client side.

* simplify test a little, remove waits

* fixture json format


Co-authored-by: Gleb Bahmutov <gleb.bahmutov@gmail.com>
2019-11-27 10:22:50 -05:00
Zach Bloomquist
249db45363 Use websockets to stub large XHR response bodies instead of hea… (#5525)
* server: add test for XHR with body > 100kb via CLI

* Use websockets to stub large XHR response bodies instead of headers

* Properly cleanup outstanding XHRs on before:test:run

* Add lil unit test for xhr_ws_server

* Use reset:xhr:server to get around sending entire test:before:run:async payload

* Responding to feedback

* Implement feedback

* move data obj wrapping into xhrs controller
2019-10-30 16:36:02 -04:00
Gleb Bahmutov
94128a97e3 Fix decoding unicode values in the config object passed to the browser (#5451)
* correctly decode runner config

* add comments with original issue

* remove stray branch name to build
2019-10-24 16:52:08 -04:00
Chris Breiding
6ba8d7cc93 Electron v5.0.10 (#4720)
* fix specs

* use debugger protocol for cookie handling in electron

* use latest gulp

* use rimraf instead of gulp-clean

* use electron 3.1.8 and node 10.2.1

* use gulp 4 in packages/static

* fix sendCommandAsync, log Schema.getDomains on CDP connect

* autofill e2e test name [skip ci]

* electron@5.0.7, see what new failures exist

* --no-sandbox for launching Electron

* update cookies logic for electron

* node 12

* update snapshot for new node

* update error message for new node

* stub sendCommandAsync

* only connect to socket if path has been replaced, fixes #4776

* update node-sass to support node 12

* skip wacky socket tests for now

* snapshot

* fix run_plugins_spec snapshot, don't include stack trace

* use --no-sandbox on linux to run as root

* allow sendCommandAsync to resolve

* use euid for root check

* log domains even if undefined

* don't worry about ending 1xx responses immediately anymore

* use --max-http-header-size, change max size from 8kb to 1mb, fix #76

* do not send 502 on failed websocket, just send back ECONNRESET

* update websocket spec port to not collide with other test

* update outdated expect

* Revert "only connect to socket if path has been replaced, fixes #4776"

This reverts commit f179eda5ca.

* update gulp in root

* update https-proxy unit tests

* update network spec to properly close server

* update reporter spec

* update https-proxy-agent to fix node 10.10.0 change

discussion: https://github.com/nodejs/node/issues/24474\#issuecomment-511963799

* only pass --max-http-header-size on node >=12

* use own server-destroy implementation that supports secureConnect events

* oops

* update socket_spec

* electron 6.0.0

* console.table introduced in node 10

* change browserify entry to init.js

* handle edge case when no response body

* console.table added in node 10

* do not exit app when all BrowserWindows are closed

* update e2e snapshots

* value may not be null

* update plugins spec

* correct cookie expiry, use browser.getversion for CDP version check

* fix snapshotting for require stacks

* reorder cookies in spec

* warn when depreated electron callback apis are used

* only report 1 plugin error per process

* cleanup

* node 12.4.0, cypress/browsers:node12.4.0-chrome76 docker image

* update shell.openExternal to promisified

* update dialog.showOpenDialog to promisified

* update webContents.session.setProxy to promisified

* updating native dependencies since we don't need ancient node ABI support anymore

* WIP: switch cookies to simpler, jar-less approach

* WIP: switch cookies to simpler, jar-less approach

* making tests pass

* improve cookie filtering logic

* Remove unneeded Promise.try

* filter what makes it to the extension

* properly re-set superdomain cookies on cross-origin cy.visit

* allow comma-separated list of e2e tests

* sort cookies in order of expiration date, ascending

* updating tests, cleanup

* update tests

* version electron as a devDependency, electron@6.0.1

* cleanup, remove old automation

* cleanup, remove old automation

* bump chokidar to fix win10 + node12 issue

was seeing this on windows:
https://github.com/nuxt/nuxt.js/issues/6035

fixed with version bump

* enable now-supported quit role, re-enable old tests

* don't need that arg there

* remove last deprecated callback electron invocations

* Delete cypress.json

* responding to PR feedback

* cleanup

* invoke

* use 'quit' role

* Use new appMenu role for Cypress menu on mac

* electron@6.0.2

* electron@6.0.3

* remove domain: cookie.domain and see what happens

* remove setErrorHandler

* Revert "remove domain: cookie.domain and see what happens"

This reverts commit 49e916896d.

* add unit tests for cookies

* ci

* fix project-content css

* electron@6.0.4

* fix specs_list test

* electron@6.0.7

* some cleanup

* electron@6.0.9

* Update 8_reporters_spec.coffee.js

* electron@5.0.10 - Chromium 73, Node 12

* cli: fix the STDIN pipe on Windows (#5045)

* cli: pipe stdin

* uggh, here is the actual change

* update cli unit tests

* add unit test

* more permissive check for json to include application/vnd.api+j… (#5166)

* more permissive check for json to include

* add json test for content-type application/vnd.api+json

* cruder solution passes e2e tests locally, so let's go with that

* Remove 'charset' from content-type before checking if JSON

* fix eslint for fixture specs (#5176)

* update eslint to lint files within 'fixtures' in support files

- ignore some edge cases like jquery, jsx and obvious js files we wrote
with broken code

* Fixes from eslint to 'fixtures' files

* Catch env variable with reserved name CYPRESS_ENV 1621 (#1626)

* server: check CYPRESS_ENV variable when merging configs

* catch invalid CYPRESS_ENV value in CLI, close #1621

* linting

* sanitize platform in test snapshot

* linting

* update error message text

* add missing comma

* fix finally merge in JS code

* pass CLI linter

* fix log reference, should be debug

* use correct sinon reference

* update message, show first part in red

* update error message text

* Addresses #2953 (#5174)

* Addresses #2953

* Added proper test for new error message

* Didn't realize it ran this test as well, whoops

* Implementing changes as suggested by @jennifer-shehane

* Fixing tests and error output. Moved the checks to the start of the get command to ensure we always catch improper options

* Removing issue test since the querying spec covers it

* Using coffescript isArray check

* depromisify things that were promisified b/t electron 5 <=> 6

Revert "update shell.openExternal to promisified"

This reverts commit 8b6460d015.

Revert "update dialog.showOpenDialog to promisified"

This reverts commit 5f178b075b.

Revert "update webContents.session.setProxy to promisified"

This reverts commit 727df3a4e5.

* node12.4.0-chrome76 => node12.0.0-chrome75

* fix tests for electron downgrade

* node12.0.0-chrome75 => node12.0.0-chrome73


Co-authored-by: Zach Bloomquist <github@chary.us>
Co-authored-by: Brian Mann <brian.mann86@gmail.com>
2019-09-24 14:35:24 -04:00
Zach Bloomquist
8cde36eacc base64 encode the embedded runner config object so it can't b… (#5155)
* base64 encode the config so it can't be escaped

* update tests
2019-09-17 15:51:15 -04:00
Ben Kucera
7857dac907 [internal] use webpack for builds (#4103)
* add webpack

* fix build proccess

* fix reporter build and test

* fix reporter test .css

* use apply(window, ...) since strict mode in webpack

* temp 05/13/19 [skip ci] resolver

* temp 05/14/19 [skip ci] webpack w/ root level symlinks

* run ci

* minor fixes

* fix link-packages script

* hopefully fix mac build

* re-add build-prod script in reporter

* fix typo in link-packages script

* fix lint errors

* fix node-version

* namespace files in webpack

* bust circle ci cache

* bust circle ci cache 2

* remove deps

* bust circle ci cache 3

* bust circle ci cache (launcher)

* ok circleci, you win. I will change all the cache keys

* update snapshot: not sure why added stack lines

* add mocha to reporter devDeps

* separate build file for reporter

* remove unneeded code

* node-sass-globbing use relative imports for appveyor

* add debugging for appveyor failure

* node-sass-globbing force unix paths for windows

* node-sass-globbing force unix paths for windows 2

* node-sass-globbing force unix paths for windows in runner

* run ci

* add checksum to packages caches

* bust circle ci cache (sub packages)

* testing code for appveyor env vars

* fix appveyor env vars for branchname
06-00000026

* fix binary build script, smoke test catch errors, include pkg mains
03-0000000a

* build binary in appveyor for this branch
07-00000047

* fix binary unit test, revert mocha upgrade in root, fix e2e specs
02-00000004

* statically replace symlinks at build time, add test, remove proxy packages code
03-00000002

* oops, update snapshot
04-00000049

* bump circle packages cache
02-00000005

* fix path.win32 on windows, add test for it
00-00000058

* for some reason packages ci cache is not including `rebuild-node-sass` in node_modules/.bin, and npm does not recreate .bin links if a node_modules folder already exists. so Im bumping all the npm caches, again
00-00000003

* emit during webpack-dev-server watch mode
02-00000020

* try revert circle.yml
02-0000002f

* try revert everything
03-0000003b

* Revert "try revert everything"

This reverts commit be125b88ff.

* no circle cache now
02-00000013

* remove logging in reporter build
06-00002a41

* Merge branch develop of github.com:cypress-io/cypress into webpack-runner
02-0000089b

* make build scripts DRY
04-00000a7f

* fix missing fonts, better watch mode
06-00003053

* use webpack --progress in watch mode
00-00000582

* move webpack config files into dedicated package
05-000023bf

* build desktop-gui with webpack, use relative scss url()s
03-00001801

* add timings info, fix configs
07-00005582

* enable sourcemaps "eval", fix desktopgui test
04-00005a08

* try 2: fix desktopgui test
01-0000058e

* fix lint
03-00000b10

* fix snapshot (very minor do not worry)
04-000014a4

* code cleanup
00-00007a4f

* try disable devtool
07-0000a97a

* remove cypress:// devtool sourceURL mapping to prevent cross-domain on electron
00-000056e4

* re-enable eval sourcemap in dev and prod
06-000051e6

* code cleanup
02-000056ae

* refactor node-jsdom setup for tests
00-000041a2

* re-enable sourceURL protocol, enable crossorigin script on runner to appease electron

* smoke tests for static assets in binary build script, disable sourceURL protocol mapping, more consistent dev/prod webpack builds

* use cross-env for desktop-gui

* desktop-dui: expect development NODE_ENV during build script (as has been in past)

* fix build script unit test

* fix build script unit test for real

* fix sourcemaps for dev/prod, add comments, add build static asset tests

* add cross-env to runner devDeps

* fix unit tests for build binary script

* fix whitespace

* add postcss autoprefixer + staticAsset tets

* add eslintrc to scripts/unit

* tabs -> spaces

* tabs -> spaces

* fix binary/util scripts

* fix testStaticAssets in build script

* fix extension requiring node socket

* fix unit-test for binary build script

* fix unit test for runner/reporter

* disable sourcemaps/eval in production

* fix disable sourcemaps in prod code

* resort jsons w/ new lint

* linting fixes

* runner/package.json add back rebuild-node-sass

* no circle cache again

* fix circle.yml

* try appveyor again

* fix binary build: remove "timers" from server/package.json.files

* fix testStaticAssets false-positive sourcemap detection (due to diff package)

* fix 2 failing e2e tests (run in chrome for now)
use build-prod scripts in binary-build script
add build-prod scripts to all packages

* a string is no regex

* correct merge: global_mode_spec

* fix all snapshot screenshot dimensions

* fix all snapshot screenshot dimensions (again)

* fix testStaticAssets development -> production

* Revert "fix all snapshot screenshot dimensions (again)"

This reverts commit d9022ef950.

* Revert "fix all snapshot screenshot dimensions"

This reverts commit 4f7628a051.

* helpers/e2e: only normalize screenshot dimensions NOT on electron

* post-task: windows build don't build on this branch

* post-task: un-bump circleci cache

* post-task: bump circleci cache packages/node_modules to v9

* cleanup: fix eol-newline, remove unneeded eslintrc

* bump circleci cache

* run rebuild-node-sass inside webpack build config

* bump circleci cache

* use cache version from env variable on circle

* use custom command to save cache for most packages

* add custom restore cache command

* restore 2 packages separately

* allow passing package path to restore

* pass explicit path to package to restore

* add restore-caches and save-caches

* print name for restoring cache commands

* print name when storing cache

* print .bin when saving cache

* fix path to .bin

* print launcher .bin

* show .bin for desktop-gui

* print bins

* update npm version

* update npm version - try 2

* update npm version - try 3

* remove circleci debugging print commands

* Revert "remove circleci debugging print commands"

This reverts commit 248966efcd.

* add TERM=xterm to Circle

* Revert "Revert "remove circleci debugging print commands""

This reverts commit cf77273b10.

* Revert "add TERM=xterm to Circle"

This reverts commit dc77c94c57.

* remove --serial arg from run all scripts

* add web-config package to cache

* simplify circleci build job

* circleci: try rmrf node_modules/@packages before install

* appveyor: try removing --serial from install script

* Revert "appveyor: try removing --serial from install script"

This reverts commit 7ef619ff30.

* use appveyor from develop

* use preinstall removing subpackage symlinks
fix webpack config typescript errors
fix path to rebuild-node-sass in packages/web-config
assert replace minimum number of symlink requires

* test binary build [build binary]

* fix transformRequires code [build binary]
2019-07-18 12:11:27 -04:00
Zach Bloomquist
84f99e6e87 Fix a variety of character encoding issues (#4698)
* add e2e test that demonstrates encoding issue

* fix all sorts of content-type wackiness, infer content-type from html

* update snapshot

* add kr, jp, cn tests

* update snapshot

* intercept any valid JS content-type

* PR review changes
2019-07-15 12:58:56 -04:00
Jennifer Shehane
c13e94a520 remove string-to-stream dep (getStream isn't called anywhere) (#4619)
* remove string-to-stream dep (getStream isn't called anywhere)

I don’t see ‘getStream’ being called anywhere in the code, this is the
only method that uses string-to-stream

* trigger status check
2019-07-01 11:47:15 -04:00
Zach Bloomquist
74dc6e8b5e Only send cy.visit() auth options to correct protection space (#4338)
* only send auth headers to the original protection space

* cleanup

* test now fails w/o fix

* note about moving this into lib/util/uri.js

* refactor, cleanup, and provide more context

* add lots of tests around cors.urlMatchesOriginProtectionSpace

- fix some edge cases and yes… bugs due to behavior of url.format(…)
- if host is set, port value is ignored, so we must clear it out
- protocol contains a ‘:’ character, fixed the protocol + port constants
- synchronize method signatures to always return a safely cloned
url.parse(…) object
- add url notes

* have buffers use url utility

* fixes failing tests

* remove unused require


Co-authored-by: Brian Mann <brian.mann86@gmail.com>
2019-06-19 06:23:25 -04:00
Zach Bloomquist
60318a7f0f Use is-html as a fallback to check if cy.visit() response is HTML (#4321)
* use is-html as a fallback to check if response is HTML

* end response with passthru stream

* clean up network_failures

* add test that visit passes with undef content-type

* handle empty responses too

* try to fix dtslint: bump package version 2
02-00000876

* fix failing tests via develop merge


Co-authored-by: Ben Kucera <14625260+Bkucera@users.noreply.github.com>
Co-authored-by: Brian Mann <brian.mann86@gmail.com>
2019-06-19 03:05:38 -04:00
Zach Bloomquist
0c8df29def End proxied responses for 1xx, 204, 304 with no body, fix bug where cy server could be proxied (#4358)
* release 3.2.0 [skip ci]

* add failing test for 304

* always end response on 1xx, 204, or 304

* add http req spec

* add test that 1xx, 204, 304 always pass thru immediately

* cleanup

* skip stubborn test

* cleanup, tests

* fix stopping debugproxy where it hasn't been started

fix stopping debugproxy where it hasn't been started

* Never proxy websocket port

* e2e test now works

* unnecesary this

* e2e works in ci


Co-authored-by: Brian Mann <brian.mann86@gmail.com>
2019-06-19 00:19:30 -04:00
Zach Bloomquist
1f185f7f11 Fix cy.visit slowness by removing Electron timers workaround (#4385)
* add tests for getAddress on localhost

* add test for visit resolving quickly

* add debug logs to network

* network: override addRequest in HttpAgent, not createSocket

* don't need to add connection: keep-alive to all responses

https://github.com/cypress-io/cypress/pull/4385#issuecomment-499103484

* test that visit finishes quickly

* do not forward connection header

* add tests to help reproduce

* cleanup

* still send keep-alive

* update tests

* remove timers

* add snapshots to e2e test

* remove tests for debugging

* try making console writes async

* Revert "remove timers"

This reverts commit b9d65a4e5c.

* allow DEBUG_COLORS to be passed in an e2e test

* try: using system node for the timers, setting up our own IPC

* Revert "try: using system node for the timers, setting up our own IPC"

This reverts commit c51b3957e2.

* put the interesting test first

* use electron-mocha to run tests in electron

* Revert "use electron-mocha to run tests in electron"

This reverts commit 8b82f0eeb3.

* support legacy addRequest invocation

* Revert "Revert "remove timers""

This reverts commit 93f15fcb17.

* update snapshot

* Revert "try making console writes async"

This reverts commit 9c8337e433.

* complete in 150ms, not 1000ms
2019-06-17 12:41:22 -04:00
Zach Bloomquist
6b1d686ed2 Don't send Cypress error HTML on network errors (#4105)
* retry requests, basic e2e test

* basic e2e test for chrome behavior

* don't use timeouts to test

* some minor cleanup

* validate google chrome's retry behavior w/ a proxy

* get retries on network errors workin

* cleanup

* final changes before switching approach

* Reverting previous approach in request.coffee, server.coffee

* add retryOnNetworkFailure

* now works with retryOnStatusCodeFailure

* retry 4 times in addition to the 1 initial attempt

* add tests for subresources

* much improved error handling

* have the e2e test really work

* e2e baseurl check

* retry baseurl check

* remove special handling for node 8.2.1 bug

* WIP: continue making progress building out request retry

- swap out passthrough’s for pumpify / duplexify / pump
- clean up error handling / messaging / retry logic

* pipe clientrequest events

* buffer req body to disk, restore error handling/retrying

* don't bubble up errors from failed attempts

* actually pipe reqstream, oops

* add some e2e tests for request body

* revert lib/request.coffee to 7be1051

* add almost-working lazy-stream

* manually fire the 'pipe' event on the reqStream to copy headers to the outgoing message

- restore the ‘error’ propagation so that all tests pass for now

* cleanup leaking 'undefined' into stdout, causing failing e2e tests

- do not set onWarning as a property of project, just pass as an
argument

* add new options to request_spec, deduplicate default opts

* use stream buffer in request.coffee

* revert request.coffee

* last stream_buffer changes before removing fs stuff

* remove fs stuff from stream_buffer, add stream piping tests

* it works! :tada::tada:🎉 using duplexify to separate delayStream and reqBodyBuffer

* retry for .5s max on ECONNREFUSED

* add error codes

* don't timeout proxied requests

* restore baseurl check

* update new e2e tests

* make delay work with rp

* propagate clientresponse events

* removing tests that don't do anything now that we don't ESOCKETTIMEOUT on proxied requests

* add new visit, req options to index.d.ts

* don't fail on server-performance-test

* make retries with status code work again

* account for different stack trace in ci

* fix test

* retry https requests

* add tests for https passthru retries working

* clean up error handling for https-proxy

* fix failing https-proxy tests, tweak agent error handling to prevent multiple callbacks

* make expectedExitCode actual vs. expected in the correct order

* bump up e2e test timeout so it can retry and still work

* don't show cypress error page on network errors, gzip errors

* update tests

* clean up onWarning code

* add tests for incompatible options errors

* retry up to 500ms on proxied requests

* remove .only

* add tests for incompatible options errors

* remove .only

* maybe this will help it act more consistently

* help e2e test work in ci

* don't re-pipe the gzip response to client, the response is already gone

In the event that a gzip response has an error and we're not doing full injecting (ie, not buffering the response in memory), we can't just re-stream it.

By the time we do the second .pipe, the stream is already empty.

So, let's just error out anyways, which is what the browser would do (error).

* remove test for injecting into net error 500 pages in iframes

* update visit spec to expect an actual error, not Cypress HTML on visit timeouts

* update el snapshot

* don't reconnect on already made connections

* clarify naming

* wip: testing https proxy

* better debug calls

* WIP: getting proxy passthrough retry tests going

* handle retrying upstream proxy errors

- add tests for successfully retrying proxy errors and for unsuccessful
retries
- fix onClose errors when proxy connection is closed before enough data
is received
- fix not returning setTimeout correctly

* group related code accordingly

* do not build typescript by default, drop extension from main

* more TODO notes

* don't set a default NO_PROXY if NO_PROXY = ''

* debugging-proxy@2.0.0

* null out reqBodyBuffer when req finishes

* wip: retry in agent, not https-proxy [skip-ci]

* update https-proxy to use @packages/network retries

* retry after connection but before proxy tunnel established

* appease my linty overlords

* update https-proxy tests

* update agent specs, decided to still use tls.connect

it's easier to test and has less complexity

* test retrying HTTPS passthru

* debugging-proxy@2.0.1

* increase defaultCommandTimeout 100 -> 200 to prevent flake in CI

* auto formatting

* fix test to be dynamic and not rely on magic constants

* copy types field when linking proxy images, update packages/network types field

* linting

* add network index.js file

* linting

* improve error messaging experience when verifying base url

* only insert 1 new line

* fix failing test not binding to localhost

* removed test that's covered by e2e specs

* remove dash in 're-try'

* some cleanup for readability

* use allocUnsafe per perf

* unset NO_PROXY with an empty string

* move retry ensuring the baseUrl into url, cleanup some imperative code

* if the head is already present during connect, make connection, else wait for first head bytes

* minor formatting, clarity around conditions, naming

* rename retryInterval -> retryIntervals

* set defaults for requests during creation for clarity

* rename send -> sendPromise to pair better with sendStream

* use retryIntervals instead of juggling MAX_REQUEST_RETRIES

- ensure debug messages are consistent between request streams +
promises
- set static constants

* DRY up status check + network failure + retry logic

- keeps the debug logic identical between promises + streams
- ensures all logic paths are also consistent
- consolidates the pop’ing of intervals in a single place

* find / replace fail

* derp

* make the logic actually correct, set intervals as cloned defaults for recursive lookup

* pass arg correctly

* reduce debugging noise, formatting

* rename intervals -> delaysRemaining for clarity

* added unit tests around getDelayForRetry

* set retryIntervals as default options correctly, add unit tests

* using single line when debugging objects

* restore snapshot to match develop

* restore snapshot and move failing tests in e2e visit around momentarily...

* WIP: add the failing tests back in

* add tests for promise/stream that we don't retry on timeouts but do retry on resets

* use create entrypoint for tests

* pass requestTimeout from cy.visit(), remove hard coded request timeout

* s/requestTimeout/responseTimeout

* clean up how we initiate the request stream

* buffer resolve:url response before resolving promise

* only persist the buffer to memory once response finishes

* update visit spec to fail with ESOCKETTIMEDOUT

* use stream.PassThrough to buffer the response stream

* always buffer response stream

* de-commit those screenshots

* buffer forever - node's default is only to buffer 16kB

* some cleanup and renaming vars

* re-remove screenshots

* do all resolution login in on(end)

* update test to call the sendRequest callback

* update comment

* enable resolving:url to cancel currently in flight promises and abort pending requests

* add test for only having one request in flight at a time

* test currentPromisePhase too

* make tests fast again™️

* cleanup the coffeescript conversion, use common-tags, and use res.end to write final chunk

* add test ensuring that responseTimeout is passed correctly when resolving the url via cy.visit()

* micro-opt to check if err.code is property of zlib.constants

* always destroy the request socket when gzip fails as opposed to forwarding the broken bytes

* cleanup, formatting


Co-authored-by: Brian Mann <brian.mann86@gmail.com>
Co-authored-by: Jennifer Shehane <jennifer@cypress.io>
2019-05-17 02:55:51 -04:00
Zach Bloomquist
b8a6baaca3 Retry certain requests on failure (#4015)
* retry requests, basic e2e test

* basic e2e test for chrome behavior

* don't use timeouts to test

* some minor cleanup

* validate google chrome's retry behavior w/ a proxy

* get retries on network errors workin

* cleanup

* final changes before switching approach

* Reverting previous approach in request.coffee, server.coffee

* add retryOnNetworkFailure

* now works with retryOnStatusCodeFailure

* retry 4 times in addition to the 1 initial attempt

* add tests for subresources

* much improved error handling

* have the e2e test really work

* e2e baseurl check

* retry baseurl check

* remove special handling for node 8.2.1 bug

* WIP: continue making progress building out request retry

- swap out passthrough’s for pumpify / duplexify / pump
- clean up error handling / messaging / retry logic

* pipe clientrequest events

* buffer req body to disk, restore error handling/retrying

* don't bubble up errors from failed attempts

* actually pipe reqstream, oops

* add some e2e tests for request body

* revert lib/request.coffee to 7be1051

* add almost-working lazy-stream

* manually fire the 'pipe' event on the reqStream to copy headers to the outgoing message

- restore the ‘error’ propagation so that all tests pass for now

* cleanup leaking 'undefined' into stdout, causing failing e2e tests

- do not set onWarning as a property of project, just pass as an
argument

* add new options to request_spec, deduplicate default opts

* use stream buffer in request.coffee

* revert request.coffee

* last stream_buffer changes before removing fs stuff

* remove fs stuff from stream_buffer, add stream piping tests

* it works! :tada::tada:🎉 using duplexify to separate delayStream and reqBodyBuffer

* retry for .5s max on ECONNREFUSED

* add error codes

* don't timeout proxied requests

* restore baseurl check

* update new e2e tests

* make delay work with rp

* propagate clientresponse events

* removing tests that don't do anything now that we don't ESOCKETTIMEOUT on proxied requests

* add new visit, req options to index.d.ts

* don't fail on server-performance-test

* make retries with status code work again

* account for different stack trace in ci

* fix test

* retry https requests

* add tests for https passthru retries working

* clean up error handling for https-proxy

* fix failing https-proxy tests, tweak agent error handling to prevent multiple callbacks

* make expectedExitCode actual vs. expected in the correct order

* bump up e2e test timeout so it can retry and still work

* update tests

* retry up to 500ms on proxied requests

* add tests for incompatible options errors

* remove .only

* maybe this will help it act more consistently

* help e2e test work in ci

* don't reconnect on already made connections

* clarify naming

* wip: testing https proxy

* better debug calls

* WIP: getting proxy passthrough retry tests going

* handle retrying upstream proxy errors

- add tests for successfully retrying proxy errors and for unsuccessful
retries
- fix onClose errors when proxy connection is closed before enough data
is received
- fix not returning setTimeout correctly

* group related code accordingly

* do not build typescript by default, drop extension from main

* more TODO notes

* don't set a default NO_PROXY if NO_PROXY = ''

* debugging-proxy@2.0.0

* null out reqBodyBuffer when req finishes

* wip: retry in agent, not https-proxy [skip-ci]

* update https-proxy to use @packages/network retries

* retry after connection but before proxy tunnel established

* appease my linty overlords

* update https-proxy tests

* update agent specs, decided to still use tls.connect

it's easier to test and has less complexity

* test retrying HTTPS passthru

* debugging-proxy@2.0.1

* increase defaultCommandTimeout 100 -> 200 to prevent flake in CI

* auto formatting

* fix test to be dynamic and not rely on magic constants

* copy types field when linking proxy images, update packages/network types field

* linting

* add network index.js file

* linting

* improve error messaging experience when verifying base url

* only insert 1 new line

* fix failing test not binding to localhost

* removed test that's covered by e2e specs

* remove dash in 're-try'

* some cleanup for readability

* use allocUnsafe per perf

* unset NO_PROXY with an empty string

* move retry ensuring the baseUrl into url, cleanup some imperative code

* if the head is already present during connect, make connection, else wait for first head bytes

* minor formatting, clarity around conditions, naming

* rename retryInterval -> retryIntervals

* set defaults for requests during creation for clarity

* rename send -> sendPromise to pair better with sendStream

* use retryIntervals instead of juggling MAX_REQUEST_RETRIES

- ensure debug messages are consistent between request streams +
promises
- set static constants

* DRY up status check + network failure + retry logic

- keeps the debug logic identical between promises + streams
- ensures all logic paths are also consistent
- consolidates the pop’ing of intervals in a single place

* find / replace fail

* derp

* make the logic actually correct, set intervals as cloned defaults for recursive lookup

* pass arg correctly

* reduce debugging noise, formatting

* rename intervals -> delaysRemaining for clarity

* added unit tests around getDelayForRetry

* set retryIntervals as default options correctly, add unit tests


Co-authored-by: Brian Mann <brian.mann86@gmail.com>
Co-authored-by: Jennifer Shehane <jennifer@cypress.io>
Co-authored-by: Gleb Bahmutov <gleb.bahmutov@gmail.com>
2019-05-15 12:46:55 -04:00
Brian Mann
e31b356519 ensure aborted requests are propagated forward (#2802)
- this prevents situations where long running connections build up over
time
2018-11-19 04:52:22 -05:00
Noel Yoo
999c217751 Refactor buffer constructor (#2489) 2018-10-01 10:25:40 -04:00
Brian Mann
126933385e capture electron console logs and more debug logs (#2303) 2018-08-09 08:27:53 -04:00
Brian Mann
dc28e87fb8 add support for handling event streams / server sent events / SSE (#2054)
* WIP: fixing SSE

* adds tests and error handling for event streams

* fixes failing tests due to request dep upgrade

* whoops, make sure e2e tests finish. add snapshot
2018-06-28 06:22:38 -04:00
Brian Mann
a9d08cfebe security stripping oversight (#2031)
fixes #2030
2018-06-26 18:36:02 -04:00