Skip to content

Commit

Permalink
Merge branch 'develop' into fix-driver-retries
Browse files Browse the repository at this point in the history
  • Loading branch information
emilyrohrbough committed Oct 28, 2021
2 parents 66c2fd8 + fe4ede0 commit 2eb8ef1
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 7 deletions.
32 changes: 32 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -33,13 +50,20 @@ 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
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
Expand All @@ -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
Expand Down Expand Up @@ -343,3 +371,7 @@ $RECYCLE.BIN/

# Circle cache artifacts
globbed_node_modules

# Autogenerated files, typically from graphql-code-generator
*.gen.ts
*.gen.json
12 changes: 10 additions & 2 deletions npm/react/plugins/next/getRunWebpackSpan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
}
Expand Down
34 changes: 32 additions & 2 deletions packages/electron/README.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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.
27 changes: 27 additions & 0 deletions packages/runner-ct/cypress/component/RunnerCt.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
})
})
})
12 changes: 12 additions & 0 deletions packages/runner-shared/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
3 changes: 0 additions & 3 deletions system-tests/test/screenshots_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ describe('e2e screenshots', () => {
.then((sizes) => {
// make sure all of the values are unique
expect(sizes).to.deep.eq(_.uniq(sizes))

// png1 should not be within 1k of png2
expect(sizes[0]).not.to.be.closeTo(sizes[1], 1000)
}).then(() => {
return Promise.all([
sizeOf(screenshot1),
Expand Down

0 comments on commit 2eb8ef1

Please sign in to comment.