* Add winPropAccessor to security.js, remove other replacers
* Add start of Cypress.resolveWindowReference
* Add regexes for dot and bracket access
* Some security_spec tests pass with new injection
* Add resolveWindowReference unit tests
* Old security_spec now passes with resolveWindowReference
* Inject stub resolveWindowReference so proxy still works outside of Cypress
* wip: rewrite HTML + JS with tokenizer
* Move to using esprima + hyntax to rewrite JS + HTML
* remove comment; oneLine makes the whole thing commented
* Fix tests, apple.com edge case
* wip: add getOrSet
* Revert "wip: add getOrSet"
This reverts commit a5c647c00f.
* release 3.5.0 [skip ci]
* use recast to replace window property accesses
* replace assignments to top properly
* fix yarn.lock
* bump deps
* update integration tests
* remove old security ts?
* fix integration spec
* always ignore js interception failure
* use globalThis instead of window
* add experimentalSourceRewriting flag
* restore regex-writer spec
* fix types
* update config_spec
* add source rewriting spec
* cleanup
* simplify rewriting logic, move rules into rewriter package
* create threaded rewriting tool for non-streaming use
* update @packages/rewriter to use threads for async
* use async rewriting where convenient
* add worker-shim.js
* add performance info to debug logs
* properly handle +=, -=, ...
* add proxy, rewriter to unit-tests stage
* cleanup
* use parse5 to rewrite HTML, strip SRI
* update tests
* reorganization, cleanup
* rewrite ALL parent, top identifiers except in a few cases
* handle many JS edge cases
* ensure parse5@5.1.1 is installed
* update yarn.lock
* update tests
* add debugging, add tests
* add attempted repro for .href issue
* implement source maps + extending inline source maps
* update opts passing in proxy layer
* fix sourcemap naming structure
* update tests to account for sourcemaps
* sourcemap tests
* remote source maps work
* comment
* update rewriter tests
* clean up TODOs in resolveWindowReference
* remove @types/nock
* clean up todos in deferred-source-map-cache
* fix rewriter build script
* fix concatStream import
* bump expectedresultcount
* clean up js-rules
* threading improvements, workaround for Electron segfault
* no visit_spec for now
* fix 6_visit_spec
* update MAX_WORKER_THREADS
* add repro for #3975
* cleanup
* cleanup
* make better use of namedTypes and builders
* get rid of the horrific closureDetectionTernary
ast-types keeps track of scope, so it is unneeded
* fix #3975, #3994
* add x-sourcemap, sourcemap header support
* snap-shot-it 7.9.3
* add deferred-source-map-cache-spec
* add tests
* Throw error in driver if AST rewriting fails
* Fix "location = 'relative-url'"
* fix max recursion depth
* slim down some fixtures
* fix window.location usage
* don't mess with `frames` at all
* no integration tests
* skip testing apple.com for now
* update wording: regex-based vs. ast-based
* skip real-world tests for now
* add some padding to process.exit workaround
* fix resolvers_spec
* fix html-spec
* cleanup
* Update packages/rewriter/lib/js-rules.ts
* Update packages/driver/src/cypress/resolvers.ts
* just import find by itself
* privatize typedefs for Cypress.state, remove .gitignore, remove dead code
Co-authored-by: Ben Kucera <14625260+Bkucera@users.noreply.github.com>
Server
The server is the heart of the Cypress application. All of this code represents the node process running behind the browser application. This node process is responsible for:
- Proxying every byte coming in and out of the browser
- Performing and normalizing automation tasks for each browser
- Coordinating and synchronizing state with the desktop-gui and driver packages
- Performing node specific tasks on behalf of the driver
- Instantiating and orchestrating nearly every other layer and package
- Spinning up various static file and http servers
- Communicating with our external API's
- Recording videos of run
- Managing mocha reporters
- Managing 3rd party plugins
The driver and the server are the two most complex packages of Cypress.
Developing
To run the Cypress server:
## boots the entire Cypress application
yarn start
Since the server controls nearly every aspect of Cypress, after making changes you'll need to manually restart Cypress.
Since this is slow, it's better to drive your development with tests.
Building
Note: you should not ever need to build the .js files manually. @packages/ts provides require-time transpilation when in development.
yarn lerna run build-prod --scope @packages/server --stream
yarn test-unitexecutes unit tests intest/unityarn test-integrationexecutes integration tests intest/integrationyarn test-performanceexecutes performance tests intest/performanceyarn test-e2eexecutes the large (slow) end to end tests intest/e2e
You can also use the test-watch command to rerun a test file whenever there is a change:
yarn test-watch /test/path/to/spec.js
When running e2e tests, some test projects output verbose logs. To see them run the test with DEBUG=cypress:e2e environment variable.
Running individual unit tests
yarn test <path/to/test>
yarn test test/unit/api_spec.coffee
## or
yarn test-unit api_spec ## shorthand, uses globbing to find spec
Running individual integration tests
yarn test <path/to/test>
yarn test test/integration/cli_spec.coffee
## or
yarn test-integration cli_spec ## shorthand, uses globbing to find spec
Running individual e2e tests
yarn test <path/to/test>
yarn test test/e2e/1_async_timeouts_spec.coffee
## or
yarn test-e2e 1_async ## shorthand, uses globbing to find spec
To keep the browser open after a spec run (for easier debugging and iterating on specs), you can pass the --no-exit flag to the e2e test command. Live reloading due to spec changes should also work:
yarn test test/e2e/2_go_spec.coffee --browser chrome --no-exit
Updating snaphots
Prepend SNAPSHOT_UPDATE=1 to any test command. See snap-shot-it instructions for more info.
SNAPSHOT_UPDATE=1 yarn test test/unit/api_spec.coffee
SNAPSHOT_UPDATE=1 yarn test test/integration/cli_spec.coffee
SNAPSHOT_UPDATE=1 yarn test-e2e 1_async