Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isolated runner changes #6799

Merged
merged 126 commits into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
0760a06
isolated runner changes
kuceb Mar 20, 2020
491b2e8
more fixes for isolated runner, get runner.spec passing
kuceb Mar 23, 2020
b648a8a
fix prev commit add untracked files
kuceb Mar 23, 2020
70923b4
add server reporter.spec.js for testing mocha output
kuceb Mar 23, 2020
ca9a146
fix has-binary yarn.lock
kuceb Mar 23, 2020
6161320
fix spec expected error message
kuceb Mar 23, 2020
8fcbf78
cleanup snapshot utility - use chai assert fn, add test to runner.spe…
kuceb Mar 24, 2020
2ba4fe9
remove test-retries related tests
kuceb Mar 24, 2020
13f1d01
small cleanup diff utility
kuceb Mar 26, 2020
363c898
move runner.spec to packages/runner
kuceb Mar 26, 2020
4c5a757
fix requiring missing file
kuceb Mar 27, 2020
8031a43
fix circle.yml runner-integration-tests
kuceb Mar 27, 2020
5606edf
Merge branch 'feature-test-retries' into isolated-runner-fixes
kuceb Mar 30, 2020
9c794a8
update readme
kuceb Mar 31, 2020
b4d895e
finish refactor of helpers for isolated runner-integration tests
kuceb Apr 1, 2020
683a5da
Merge branch 'feature-test-retries' into isolated-runner-fixes
kuceb Apr 3, 2020
b2b9449
restore runner/test/eslintrc
kuceb Apr 3, 2020
62d14b8
fix .eslintignore
kuceb Apr 6, 2020
e152091
temp 04/09/20 [skip ci]
kuceb Apr 9, 2020
45c8b59
Update readme to reflect how to start server for cypress tests
jennifer-shehane Apr 16, 2020
8e95c5e
Merge remote-tracking branch 'origin/develop' into isolated-runner-fixes
kuceb Apr 24, 2020
2dd7b41
try 2: fix rerun before/after hooks
kuceb Apr 27, 2020
f73126c
Merge remote-tracking branch 'origin/isolated-runner-fixes' into isol…
kuceb Apr 27, 2020
750571e
Merge remote-tracking branch 'origin/develop' into isolated-runner-fixes
kuceb Apr 27, 2020
f2dc852
Merge branch 'fix-rerun-hooks-on-navigation' into isolated-runner-fixes
kuceb Apr 27, 2020
9bd0a55
temp 04/29/20 [skip ci]
kuceb Apr 29, 2020
44c69ff
Merge remote-tracking branch 'origin/develop' into isolated-runner-fixes
kuceb Apr 29, 2020
e282289
backport changes from test-retries
kuceb Apr 29, 2020
85503d3
change logic to rerun before hooks after top navigation
kuceb Apr 30, 2020
46c116d
fix windowSize for browser e2e test
kuceb May 4, 2020
590a573
fix windowSize for xvfb chrome in e2e test
kuceb May 4, 2020
22d2780
ok fine, just disable screenshots
kuceb May 4, 2020
c82fb41
Merge branch '2-fix-rerun-hooks-on-navigation' into isolated-runner-f…
kuceb May 4, 2020
1d54dbd
Merge remote-tracking branch 'origin/develop' into isolated-runner-fixes
kuceb May 4, 2020
4c88619
fix after merge: decaffed navigation.js
kuceb May 4, 2020
edbf156
update server/unit test snapshots
kuceb May 5, 2020
b13b9de
Merge remote-tracking branch 'origin/develop' into isolated-runner-fixes
kuceb May 5, 2020
e7068e1
fix after merge: decaffed aliases.js
kuceb May 5, 2020
98408a4
fix usage of cypress --parallel flag in circle.yml
kuceb May 5, 2020
8ea4bbc
Merge remote-tracking branch 'origin/develop' into isolated-runner-fixes
kuceb May 6, 2020
8d30b64
fix circle.yml integration-tests jobs
kuceb May 6, 2020
63c61a2
fix decaf related typo
kuceb May 6, 2020
aacc763
fix circle.yml separate command for runner-integration-tests
kuceb May 6, 2020
7777d5a
update runner/integration tests + snapshot after error improvements
kuceb May 7, 2020
f0e0cd6
Merge remote-tracking branch 'origin/develop' into isolated-runner-fixes
kuceb May 7, 2020
8acbd6d
fix runner/integration snapshots for chrome/ff stacktrace differences
kuceb May 7, 2020
f82be9e
rerun ci
kuceb May 7, 2020
d3ed77d
fix passing --parallel to runner-integration tests
kuceb May 7, 2020
6d1451d
Merge remote-tracking branch 'origin/develop' into 2-fix-rerun-hooks-…
kuceb May 7, 2020
ec77ac3
perf: faster lookup for hooks without runnables
kuceb May 7, 2020
751e752
Merge remote-tracking branch 'origin/develop' into 2-fix-rerun-hooks-…
kuceb May 8, 2020
6790888
fix afterAll hook switch logic
kuceb May 8, 2020
2f06046
backport to before/after fix
kuceb May 20, 2020
75bf3bf
Merge remote-tracking branch 'origin/develop' into 2-fix-rerun-hooks-…
kuceb May 20, 2020
d230c17
backport to before/after fix 2
kuceb May 20, 2020
fe79190
Merge remote-tracking branch 'origin/2-fix-rerun-hooks-on-navigation'…
kuceb May 12, 2020
2e3993c
cleanup from decaf, fix ui/package.json
kuceb May 20, 2020
52d7166
update helpers, simplify runner.spec
kuceb May 20, 2020
73ee906
fix lint-types errors, flaky spec
kuceb May 20, 2020
f2977b7
fix noExit passed to e2e test inline options
kuceb May 22, 2020
836fc0a
Merge remote-tracking branch 'origin/develop' into 2-fix-rerun-hooks-…
kuceb May 22, 2020
70b9b09
Merge remote-tracking branch 'origin/2-fix-rerun-hooks-on-navigation'…
kuceb May 22, 2020
16be5c2
cleanup snapshot utility - refactor to use util file
kuceb May 22, 2020
bee8408
remove before/after changes
kuceb May 26, 2020
2a1fc2a
Merge remote-tracking branch 'origin/develop' into isolated-runner-fixes
kuceb May 26, 2020
d82f8b4
make cy obj a class instance
kuceb May 26, 2020
90ba8ba
cleanup/unmerge before/after fixes PR...
kuceb May 26, 2020
6500edc
more cleanup
kuceb May 26, 2020
156d51b
add comment
kuceb May 28, 2020
5a8e064
Merge remote-tracking branch 'origin/develop' into isolated-runner-fixes
kuceb May 28, 2020
e57b576
fix runner.spec
kuceb Jun 1, 2020
a77a0b6
Merge remote-tracking branch 'origin/develop' into isolated-runner-fixes
kuceb Jun 3, 2020
93943e5
Merge remote-tracking branch 'origin/develop' into isolated-runner-fixes
kuceb Jun 4, 2020
ece0481
cleanup snapshot utility more, cleanup reporter.spec
kuceb Jun 4, 2020
aaf657f
Merge remote-tracking branch 'origin/develop' into isolated-runner-fixes
kuceb Jun 8, 2020
230ffef
minor rename variable
kuceb Jun 8, 2020
1378233
Merge remote-tracking branch 'origin/develop' into isolated-runner-fixes
kuceb Jun 8, 2020
edd75b0
fix specName in reporterHeader, spec_helper require
kuceb Jun 8, 2020
9143eef
replace reporter specPath usages with spec object from config
kuceb Jun 8, 2020
1348b35
cleanup, fix specs, fix types tests
kuceb Jun 8, 2020
87db3c8
Merge branch 'chore-refactor-specpath-reporter-use' into isolated-run…
kuceb Jun 9, 2020
1ab5d71
fix config spec paths in isolated runner, fix snapshot plugin button
kuceb Jun 9, 2020
9211e53
combine runner.spec.js and runner_spec.js
kuceb Jun 9, 2020
5a9a7a8
fix incorrect merge
kuceb Jun 9, 2020
fec95de
minor minor cleanup
kuceb Jun 9, 2020
0872413
rename driver/test/cypress to driver/test
kuceb Jun 9, 2020
f658ea6
use yarn workspace over lerna for individual package commands
kuceb Jun 9, 2020
042b9bb
Merge branch 'chore-use-yarn-workspaces-over-lerna' into chore-move-d…
kuceb Jun 9, 2020
18239dd
add error message to driver start
kuceb Jun 9, 2020
ffd7875
remove usage of wait-on
kuceb Jun 9, 2020
b696f6b
update <reference types/>, import string
kuceb Jun 10, 2020
72a3fce
Merge remote-tracking branch 'origin/develop' into chore-move-driver-…
kuceb Jun 10, 2020
3888716
fix driver/readme
kuceb Jun 10, 2020
ab57cdc
fix readmes after regex replace
kuceb Jun 10, 2020
ca20729
Merge remote-tracking branch 'origin/develop' into chore-use-yarn-wor…
kuceb Jun 10, 2020
3c2927b
Merge branch 'chore-use-yarn-workspaces-over-lerna' into chore-move-d…
kuceb Jun 10, 2020
6de684c
revert wait-on changes
kuceb Jun 10, 2020
fc56b8e
Merge branch 'chore-use-yarn-workspaces-over-lerna' into chore-move-d…
kuceb Jun 10, 2020
930b718
Revert "revert wait-on changes"
kuceb Jun 10, 2020
f2b8c4e
update yarn.lock
kuceb Jun 10, 2020
e6bcb4f
fix broken path in spec
kuceb Jun 10, 2020
55a16cb
fix broken paths in specs with @packages/driver
kuceb Jun 10, 2020
df9d0d4
move runner/test/cypress into runner/cypress
kuceb Jun 10, 2020
7d736cc
Merge branch 'chore-move-driver-tests-into-parent' into isolated-runn…
kuceb Jun 10, 2020
002d037
start server in pluginsFile in runner/cypress tests
kuceb Jun 10, 2020
1f78711
fix more broken spec paths
kuceb Jun 10, 2020
35619a7
Merge branch 'chore-move-driver-tests-into-parent' into isolated-runn…
kuceb Jun 10, 2020
6d5d32e
fix broken paths after runner/cypress folder move
kuceb Jun 10, 2020
cd7b49f
Merge remote-tracking branch 'origin/chore-use-yarn-workspaces-over-l…
kuceb Jun 10, 2020
8fc44d2
Merge remote-tracking branch 'origin/develop' into chore-move-driver-…
kuceb Jun 10, 2020
748b9a7
Merge branch 'chore-move-driver-tests-into-parent' into isolated-runn…
kuceb Jun 10, 2020
f1f9dde
move type definition loading for driver/cypress into dedicated file
kuceb Jun 10, 2020
b696fbb
move internal-types to "types" folder, fix driver/index.d.ts
kuceb Jun 10, 2020
c091b20
Merge branch 'develop' into isolated-runner-fixes
brian-mann Jun 11, 2020
0c7dffa
Merge branch 'develop' into chore-move-driver-tests-into-parent
brian-mann Jun 11, 2020
8882130
fix type-check in packages/runner. not exactly sure why
kuceb Jun 11, 2020
096bbf9
fix runner type-check by excluding test folder in tsconfig
kuceb Jun 11, 2020
e3257bf
bump timeout on e2e/8_error_ui_spec
kuceb Jun 11, 2020
f5bc2ed
update snapshot utility, rename tests in runner/runner.spec, fix READ…
kuceb Jun 11, 2020
5597ec4
Merge branch 'chore-move-driver-tests-into-parent' into isolated-runn…
kuceb Jun 11, 2020
fe5ece1
Merge remote-tracking branch 'origin/develop' into chore-move-driver-…
kuceb Jun 11, 2020
3f4d7df
Merge branch 'chore-move-driver-tests-into-parent' into isolated-runn…
kuceb Jun 11, 2020
c19f6c2
fix snapshot naming, remove redundant test in reporter_spec
kuceb Jun 12, 2020
489be5d
rename runner snapshot file
kuceb Jun 15, 2020
4ea9cbe
address feedback: move server reporter snapshot specs out
kuceb Jun 16, 2020
1a0ac78
address feedback: add comment about exposing globals
kuceb Jun 16, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 40 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,25 @@ commands:
path: /tmp/artifacts
- store-npm-logs

run-runner-integration-tests:
parameters:
browser:
description: browser shortname to target
type: string
steps:
- attach_workspace:
at: ~/
- run:
command: |
CYPRESS_KONFIG_ENV=production \
CYPRESS_RECORD_KEY=$PACKAGES_RECORD_KEY \
yarn workspace @packages/runner cypress:run --record --parallel --group runner-integration-<< parameters.browser >> --browser <<parameters.browser>>
- store_test_results:
path: /tmp/cypress
- store_artifacts:
path: /tmp/artifacts
- store-npm-logs

run-e2e-tests:
parameters:
browser:
Expand Down Expand Up @@ -653,6 +672,20 @@ jobs:
browser: firefox
chunk: "8"

"runner-integration-tests-chrome":
<<: *defaults
parallelism: 2
steps:
- run-runner-integration-tests:
browser: chrome

"runner-integration-tests-firefox":
<<: *defaults
parallelism: 2
steps:
- run-runner-integration-tests:
browser: firefox

"driver-integration-tests-chrome":
<<: *defaults
parallelism: 5
Expand Down Expand Up @@ -1486,6 +1519,13 @@ linux-workflow: &linux-workflow
- driver-integration-tests-firefox:
requires:
- build
- runner-integration-tests-chrome:
requires:
- build
- runner-integration-tests-firefox:
requires:
- build

## TODO: add these back in when flaky tests are fixed
# - driver-integration-tests-electron:
# requires:
Expand Down
23 changes: 23 additions & 0 deletions packages/driver/cypress/fixtures/isolated-runner.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>

<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>


<link rel="stylesheet" href="/isolated-runner/cypress_runner.css">
</head>

<body>
<div id="app"></div>
<script type="text/javascript">
// set a global so we know the 'top' window
window.Cypress = true

</script>
<script type="text/javascript" src="/isolated-runner/cypress_runner.js"></script>
</body>

</html>
3 changes: 3 additions & 0 deletions packages/driver/cypress/plugins/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ ports.forEach((port) => {
})
})

// allows us to serve the testrunner into an iframe for testing
app.use('/isolated-runner', express.static(path.join(__dirname, '../../../runner/dist')))

app.get('/node_modules/*', (req, res) => {
return res.sendFile(path.join('node_modules', req.params[0]), {
root: path.join(__dirname, '../..'),
Expand Down
15 changes: 7 additions & 8 deletions packages/driver/src/cy/aliases.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* globals cy */
const _ = require('lodash')

const $errUtils = require('../cypress/error_utils')
Expand Down Expand Up @@ -44,30 +43,30 @@ const validateAlias = (alias) => {
}
}

const create = (state) => {
const create = (cy) => {
const addAlias = (ctx, aliasObj) => {
const { alias, subject } = aliasObj

const aliases = state('aliases') || {}
const aliases = cy.state('aliases') || {}

aliases[alias] = aliasObj
state('aliases', aliases)
cy.state('aliases', aliases)

const remoteSubject = cy.getRemotejQueryInstance(subject)

ctx[alias] = remoteSubject ?? subject
}

const getNextAlias = () => {
const next = state('current').get('next')
const next = cy.state('current').get('next')

if (next && (next.get('name') === 'as')) {
return next.get('args')[0]
}
}

const getAlias = (name, cmd, log) => {
const aliases = state('aliases') || {}
const aliases = cy.state('aliases') || {}

// bail if the name doesnt reference an alias
if (!aliasRe.test(name)) {
Expand All @@ -85,7 +84,7 @@ const create = (state) => {
}

const getAvailableAliases = () => {
const aliases = state('aliases')
const aliases = cy.state('aliases')

if (!aliases) {
return []
Expand All @@ -108,7 +107,7 @@ const create = (state) => {
})
}

cmd = cmd ?? ((log && log.get('name')) || state('current').get('name'))
cmd = cmd ?? ((log && log.get('name')) || cy.state('current').get('name'))
displayName = aliasDisplayName(name)

const errPath = availableAliases.length
Expand Down
31 changes: 15 additions & 16 deletions packages/driver/src/cy/assertions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* global cy Cypress */
const _ = require('lodash')
const Promise = require('bluebird')

Expand Down Expand Up @@ -70,14 +69,14 @@ const parseValueActualAndExpected = (value, actual, expected) => {
return obj
}

const create = function (state, queue, retryFn) {
const create = function (Cypress, cy) {
const getUpcomingAssertions = () => {
const index = state('index') + 1
const index = cy.state('index') + 1

const assertions = []

// grab the rest of the queue'd commands
for (let cmd of queue.slice(index).get()) {
for (let cmd of cy.queue.slice(index).get()) {
// don't break on utilities, just skip over them
if (cmd.is('utility')) {
continue
Expand Down Expand Up @@ -111,12 +110,12 @@ const create = function (state, queue, retryFn) {
// them up with existing ones
cmd.set('assertionIndex', 0)

if (state('current') != null) {
state('current').set('currentAssertionCommand', cmd)
if (cy.state('current') != null) {
cy.state('current').set('currentAssertionCommand', cmd)
}

return cmd.get('fn').originalFn.apply(
state('ctx'),
cy.state('ctx'),
[subject].concat(cmd.get('args')),
)
})
Expand All @@ -139,7 +138,7 @@ const create = function (state, queue, retryFn) {
const verifyUpcomingAssertions = function (subject, options = {}, callbacks = {}) {
const cmds = getUpcomingAssertions()

state('upcomingAssertions', cmds)
cy.state('upcomingAssertions', cmds)

// we're applying the default assertion in the
// case where there are no upcoming assertion commands
Expand Down Expand Up @@ -234,7 +233,7 @@ const create = function (state, queue, retryFn) {
}

if (_.isFunction(onRetry)) {
return retryFn(onRetry, options)
return cy.retry(onRetry, options)
}
}

Expand Down Expand Up @@ -264,7 +263,7 @@ const create = function (state, queue, retryFn) {
}

// when we do immediately unbind this function
state('onBeforeLog', null)
cy.state('onBeforeLog', null)

const insertNewLog = (log) => {
cmd.log(log)
Expand Down Expand Up @@ -347,7 +346,7 @@ const create = function (state, queue, retryFn) {
return insertNewLog(log)
}

state('onBeforeLog', setCommandLog)
cy.state('onBeforeLog', setCommandLog)

// send verify=true as the last arg
return assertFn.apply(this, args.concat(true))
Expand Down Expand Up @@ -387,16 +386,16 @@ const create = function (state, queue, retryFn) {
}

const restore = () => {
state('upcomingAssertions', [])
cy.state('upcomingAssertions', [])

// no matter what we need to
// restore the assert fn
return state('overrideAssert', undefined)
return cy.state('overrideAssert', undefined)
}

// store this in case our test ends early
// and we reset between tests
state('overrideAssert', overrideAssert)
cy.state('overrideAssert', overrideAssert)

return Promise
.reduce(fns, assertions, [subject])
Expand Down Expand Up @@ -465,7 +464,7 @@ const create = function (state, queue, retryFn) {
// if our current command is an assertion type
isAssertionType(current) ||
// are we currently verifying assertions?
(state('upcomingAssertions') && state('upcomingAssertions').length > 0) ||
(cy.state('upcomingAssertions') && cy.state('upcomingAssertions').length > 0) ||
// did the function have arguments
functionHadArguments(current)
}
Expand Down Expand Up @@ -509,7 +508,7 @@ const create = function (state, queue, retryFn) {
const assert = function (...args) {
// if we've temporarily overriden assertions
// then just bail early with this function
const fn = state('overrideAssert') || assertFn
const fn = cy.state('overrideAssert') || assertFn

return fn.apply(this, args)
}
Expand Down
9 changes: 8 additions & 1 deletion packages/driver/src/cy/commands/agents.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const onInvoke = function (Cypress, obj, args) {
error: obj.error,
type: 'parent',
end: true,
snapshot: true,
snapshot: !agent._noSnapshot,
event: true,
consoleProps () {
const consoleObj = {}
Expand Down Expand Up @@ -218,6 +218,13 @@ module.exports = function (Commands, Cypress, cy, state) {
return agent
}

// disable DOM snapshots during log for this agent
agent.snapshot = (bool = true) => {
agent._noSnapshot = !bool

return agent
}

Comment on lines +221 to +227
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be a better / more readable API to do...

agent.log = (options) => {
  if (options && options.snapshot === false) {
     // do the thing
  }
})

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or more like agent.options or agent.logOptions

agent.as = (alias) => {
cy.validateAlias(alias)
cy.addAlias(ctx, {
Expand Down
10 changes: 5 additions & 5 deletions packages/driver/src/cy/commands/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const specifyFileByRelativePath = (url, log) => {
})
}

const aboutBlank = (win) => {
const aboutBlank = (cy, win) => {
return new Promise((resolve) => {
cy.once('window:load', resolve)

Expand Down Expand Up @@ -198,7 +198,7 @@ const formSubmitted = (Cypress, e) => {
})
}

const pageLoading = (bool, state) => {
const pageLoading = (bool, Cypress, state) => {
if (state('pageLoading') === bool) {
return
}
Expand All @@ -215,7 +215,7 @@ const stabilityChanged = (Cypress, state, config, stable) => {
// if we're currently visiting about blank
// and becoming unstable for the first time
// notifiy that we're page loading
pageLoading(true, state)
pageLoading(true, Cypress, state)

return
}
Expand All @@ -226,7 +226,7 @@ const stabilityChanged = (Cypress, state, config, stable) => {
}

// let the world know that the app is page:loading
pageLoading(!stable, state)
pageLoading(!stable, Cypress, state)

// if we aren't becoming unstable
// then just return now
Expand Down Expand Up @@ -1021,7 +1021,7 @@ module.exports = (Commands, Cypress, cy, state, config) => {
hasVisitedAboutBlank = true
currentlyVisitingAboutBlank = true

return aboutBlank(win)
return aboutBlank(cy, win)
.then(() => {
currentlyVisitingAboutBlank = false

Expand Down