Skip to content

Commit

Permalink
chore: updating v8 snapshot cache
Browse files Browse the repository at this point in the history
  • Loading branch information
cypress-bot[bot] committed May 23, 2023
1 parent dbc7fbd commit b6f93c7
Show file tree
Hide file tree
Showing 17 changed files with 305 additions and 98 deletions.
2 changes: 2 additions & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ _Released 05/23/2023 (PENDING)_
- Moved `types` condition to the front of `package.json#exports` since keys there are meant to be order-sensitive. Fixed in [#26630](https://github.com/cypress-io/cypress/pull/26630).
- Fixed an issue where newly-installed dependencies would not be detected during Component Testing setup. Addresses [#26685](https://github.com/cypress-io/cypress/issues/26685).
- Fixed a UI regression that was flashing an "empty" state inappropriately when loading the Debug page. Fixed in [#26761](https://github.com/cypress-io/cypress/pull/26761).
- Fixed an issue in Component Testing setup where TypeScript version 5 was not properly detected. Fixes [#26204](https://github.com/cypress-io/cypress/issues/26204).

**Misc:**

- Updated styling & content of Cypress Cloud slideshows when not logged in or no runs have been recorded. Addresses [#26181](https://github.com/cypress-io/cypress/issues/26181).
- Changed the nomenclature of 'processing' to 'compressing' when terminal video output is printed during a run. Addresses [#26657](https://github.com/cypress-io/cypress/issues/26657).
- Changed the nomenclature of 'Upload Results' to 'Uploading Screenshots & Videos' when terminal output is printed during a run. Addresses [#26759](https://github.com/cypress-io/cypress/issues/26759).

## 12.12.0

Expand Down
6 changes: 5 additions & 1 deletion packages/data-context/src/sources/UtilDataSource.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fetch from 'cross-fetch'
import type { DataContext } from '../DataContext'
import { isDependencyInstalled } from '@packages/scaffold-config'
import { isDependencyInstalled, isDependencyInstalledByName } from '@packages/scaffold-config'

// Require rather than import since data-context is stricter than network and there are a fair amount of errors in agent.
const { agent } = require('@packages/network')
Expand All @@ -23,4 +23,8 @@ export class UtilDataSource {
isDependencyInstalled (dependency: Cypress.CypressComponentDependency, projectPath: string) {
return isDependencyInstalled(dependency, projectPath)
}

isDependencyInstalledByName (packageName: string, projectPath: string) {
return isDependencyInstalledByName(packageName, projectPath)
}
}
75 changes: 36 additions & 39 deletions packages/data-context/src/sources/VersionsDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import type { DataContext } from '..'
import type { TestingType } from '@packages/types'
import { CYPRESS_REMOTE_MANIFEST_URL, NPM_CYPRESS_REGISTRY_URL } from '@packages/types'
import Debug from 'debug'
import { WIZARD_DEPENDENCIES } from '@packages/scaffold-config'
import semver from 'semver'
import { dependencyNamesToDetect } from '@packages/scaffold-config'

const debug = Debug('cypress:data-context:sources:VersionsDataSource')

Expand Down Expand Up @@ -161,45 +160,43 @@ export class VersionsDataSource {
}
}

try {
const projectPath = this.ctx.currentProject

if (projectPath) {
const dependenciesToCheck = WIZARD_DEPENDENCIES

debug('Checking %d dependencies in project', dependenciesToCheck.length)
// Check all dependencies of interest in parallel
const dependencyResults = await Promise.allSettled(
dependenciesToCheck.map(async (dependency) => {
const result = await this.ctx.util.isDependencyInstalled(dependency, projectPath)

// If a dependency isn't satisfied then we are no longer interested in it,
// exclude from further processing by rejecting promise
if (!result.satisfied) {
throw new Error('Unsatisfied dependency')
}

// We only want major version, fallback to `-1` if we couldn't detect version
const majorVersion = result.detectedVersion ? semver.major(result.detectedVersion) : -1

// For any satisfied dependencies, build a `package@version` string
return `${result.dependency.package}@${majorVersion}`
}),
)
// Take any dependencies that were found and combine into comma-separated string
const headerValue = dependencyResults
.filter(this.isFulfilled)
.map((result) => result.value)
.join(',')

if (headerValue) {
manifestHeaders['x-dependencies'] = headerValue
if (this._initialLaunch) {
try {
const projectPath = this.ctx.currentProject

if (projectPath) {
debug('Checking %d dependencies in project', dependencyNamesToDetect.length)
// Check all dependencies of interest in parallel
const dependencyResults = await Promise.allSettled(
dependencyNamesToDetect.map(async (dependency) => {
const result = await this.ctx.util.isDependencyInstalledByName(dependency, projectPath)

if (!result.detectedVersion) {
throw new Error(`Could not resolve dependency version for ${dependency}`)
}

// For any satisfied dependencies, build a `package@version` string
return `${result.dependency}@${result.detectedVersion}`
}),
)

// Take any dependencies that were found and combine into comma-separated string
const headerValue = dependencyResults
.filter(this.isFulfilled)
.map((result) => result.value)
.join(',')

if (headerValue) {
manifestHeaders['x-dependencies'] = headerValue
}
} else {
debug('No project path, skipping dependency check')
}
} else {
debug('No project path, skipping dependency check')
} catch (err) {
debug('Failed to detect project dependencies', err)
}
} catch (err) {
debug('Failed to detect project dependencies', err)
} else {
debug('Not initial launch of Cypress, skipping dependency check')
}

try {
Expand Down
42 changes: 26 additions & 16 deletions packages/data-context/test/unit/sources/VersionsDataSource.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('VersionsDataSource', () => {
context('.versions', () => {
let ctx: DataContext
let fetchStub: sinon.SinonStub
let isDependencyInstalledStub: sinon.SinonStub
let isDependencyInstalledByNameStub: sinon.SinonStub
let mockNow: Date = new Date()
let versionsDataSource: VersionsDataSource
let currentCypressVersion: string = pkg.version
Expand All @@ -36,12 +36,12 @@ describe('VersionsDataSource', () => {
ctx.coreData.currentTestingType = 'e2e'

fetchStub = sinon.stub()
isDependencyInstalledStub = sinon.stub()
isDependencyInstalledByNameStub = sinon.stub()
})

beforeEach(() => {
sinon.stub(ctx.util, 'fetch').callsFake(fetchStub)
sinon.stub(ctx.util, 'isDependencyInstalled').callsFake(isDependencyInstalledStub)
sinon.stub(ctx.util, 'isDependencyInstalledByName').callsFake(isDependencyInstalledByNameStub)
sinon.stub(os, 'platform').returns('darwin')
sinon.stub(os, 'arch').returns('x64')
sinon.useFakeTimers({ now: mockNow })
Expand Down Expand Up @@ -194,31 +194,41 @@ describe('VersionsDataSource', () => {
})

it('generates x-framework, x-bundler, and x-dependencies headers', async () => {
isDependencyInstalledStub.callsFake(async (dependency) => {
isDependencyInstalledByNameStub.callsFake(async (packageName) => {
// Should include any resolved dependency with a valid version
if (dependency.package === 'react') {
if (packageName === 'react') {
return {
dependency,
dependency: packageName,
detectedVersion: '1.2.3',
satisfied: true,
} as Cypress.DependencyToInstall
}

// Not satisfied dependency should be excluded
if (dependency.package === 'vue') {
if (packageName === 'vue') {
return {
dependency,
dependency: packageName,
detectedVersion: '4.5.6',
satisfied: false,
}
}

// Satisfied dependency without resolved version should result in -1
if (dependency.package === 'typescript') {
if (packageName === '@builder.io/qwik') {
return {
dependency,
dependency: packageName,
detectedVersion: '1.1.4',
}
}

if (packageName === '@playwright/experimental-ct-core') {
return {
dependency: packageName,
detectedVersion: '1.33.0',
}
}

// Dependency without resolved version should be excluded
if (packageName === 'typescript') {
return {
dependency: packageName,
detectedVersion: null,
satisfied: true,
}
}

Expand All @@ -238,7 +248,7 @@ describe('VersionsDataSource', () => {
headers: sinon.match({
'x-framework': 'react',
'x-dev-server': 'vite',
'x-dependencies': 'typescript@-1,react@1',
'x-dependencies': '[email protected],[email protected],@builder.io/[email protected],@playwright/[email protected]',
}),
},
)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/errors/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -520,9 +520,9 @@ export const AllCypressErrors = {
This error will not affect or change the exit code.`
},
CLOUD_CANNOT_UPLOAD_RESULTS: (apiErr: Error) => {
CLOUD_CANNOT_UPLOAD_ARTIFACTS: (apiErr: Error) => {
return errTemplate`\
Warning: We encountered an error while uploading results from your run.
Warning: We encountered an error while uploading screenshots & videos from your run.
These results will not be recorded.
Expand Down
2 changes: 1 addition & 1 deletion packages/errors/test/unit/visualSnapshotErrors_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ describe('visual error templates', () => {
default: [],
}
},
CLOUD_CANNOT_UPLOAD_RESULTS: () => {
CLOUD_CANNOT_UPLOAD_ARTIFACTS: () => {
const err = makeApiErr()

return {
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql/schemas/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ enum ErrorTypeEnum {
CLOUD_CANNOT_CREATE_RUN_OR_INSTANCE
CLOUD_CANNOT_PROCEED_IN_PARALLEL
CLOUD_CANNOT_PROCEED_IN_SERIAL
CLOUD_CANNOT_UPLOAD_RESULTS
CLOUD_CANNOT_UPLOAD_ARTIFACTS
CLOUD_GRAPHQL_ERROR
CLOUD_INVALID_RUN_REQUEST
CLOUD_PARALLEL_DISALLOWED
Expand Down
26 changes: 24 additions & 2 deletions packages/launchpad/cypress/e2e/open-mode.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,30 @@ describe('Launchpad: Open Mode', () => {
cy.openProject('todos', ['--e2e'])
})

it('includes `x-framework`, `x-dev-server`, and `x-dependencies` headers, even when launched in e2e mode', () => {
it('includes `x-framework`, `x-dev-server`, and `x-dependencies` headers, even when launched in e2e mode if this is the initial launch of Cypress', () => {
cy.withCtx((ctx) => {
ctx.versions['_initialLaunch'] = true
})

cy.visitLaunchpad()
cy.skipWelcome()
cy.get('h1').should('contain', 'Choose a browser')
cy.withCtx((ctx, o) => {
expect(ctx.util.fetch).to.have.been.calledWithMatch('https://download.cypress.io/desktop.json', {
headers: {
'x-framework': 'react',
'x-dev-server': 'webpack',
'x-dependencies': '[email protected]',
},
})
})
})

it('does not include `x-dependencies` header, if this is not the initial launch of Cypress', () => {
cy.withCtx((ctx) => {
ctx.versions['_initialLaunch'] = false
})

cy.visitLaunchpad()
cy.skipWelcome()
cy.get('h1').should('contain', 'Choose a browser')
Expand All @@ -74,7 +97,6 @@ describe('Launchpad: Open Mode', () => {
headers: {
'x-framework': 'react',
'x-dev-server': 'webpack',
'x-dependencies': 'typescript@4',
},
})
})
Expand Down
77 changes: 76 additions & 1 deletion packages/scaffold-config/src/dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const WIZARD_DEPENDENCY_TYPESCRIPT = {
package: 'typescript',
installer: 'typescript',
description: 'TypeScript is a language for application-scale JavaScript',
minVersion: '^=3.4.0 || ^=4.0.0' || '^=5.0.0',
minVersion: '^=3.4.0 || ^=4.0.0 || ^=5.0.0',
} as const

export const WIZARD_DEPENDENCY_REACT_SCRIPTS = {
Expand Down Expand Up @@ -175,3 +175,78 @@ export const WIZARD_BUNDLERS = [
WIZARD_DEPENDENCY_WEBPACK,
WIZARD_DEPENDENCY_VITE,
] as const

const componentDependenciesOfInterest = [
'@angular/cli',
'@angular-devkit/build-angular',
'@angular/core',
'@angular/common',
'@angular/platform-browser-dynamic',
'react',
'react-dom',
'react-scripts',
'vue',
'@vue/cli-service',
'svelte',
'solid-js',
'lit',
'preact',
'preact-cli',
'ember',
'@stencil/core',
'@builder.io/qwik',
'alpinejs',
'@glimmer/component',
'typescript',
]

const bundlerDependenciesOfInterest = [
'vite',
'webpack',
'parcel',
'rollup',
'snowpack',
]

const testingDependenciesOfInterest = [
'jest',
'jsdom',
'jest-preview',
'storybook',
'@storybook/addon-interactions',
'@storybook/addon-a11y',
'chromatic',
'@testing-library/react',
'@testing-library/react-hooks',
'@testing-library/dom',
'@testing-library/jest-dom',
'@testing-library/cypress',
'@testing-library/user-event',
'@testing-library/vue',
'@testing-library/svelte',
'@testing-library/preact',
'happy-dom',
'vitest',
'vitest-preview',
'selenium-webdriver',
'nightwatch',
'karma',
'playwright',
'playwright-core',
'@playwright/experimental-ct-core',
'@playwright/experimental-ct-react',
'@playwright/experimental-ct-svelte',
'@playwright/experimental-ct-vue',
'@playwright/experimental-ct-vue2',
'@playwright/experimental-ct-solid',
'@playwright/experimental-ct-react17',
'axe-core',
'jest-axe',
'enzyme',
]

export const dependencyNamesToDetect = [
...componentDependenciesOfInterest,
...bundlerDependenciesOfInterest,
...testingDependenciesOfInterest,
]
Loading

5 comments on commit b6f93c7

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on b6f93c7 May 23, 2023

Choose a reason for hiding this comment

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

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.12.1/linux-arm64/update-v8-snapshot-cache-on-develop-b6f93c7fc2cd7226e15b8b2d66de2a4bc58ef581/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on b6f93c7 May 23, 2023

Choose a reason for hiding this comment

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

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.12.1/linux-x64/update-v8-snapshot-cache-on-develop-b6f93c7fc2cd7226e15b8b2d66de2a4bc58ef581/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on b6f93c7 May 23, 2023

Choose a reason for hiding this comment

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

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.12.1/darwin-arm64/update-v8-snapshot-cache-on-develop-b6f93c7fc2cd7226e15b8b2d66de2a4bc58ef581/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on b6f93c7 May 23, 2023

Choose a reason for hiding this comment

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

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.12.1/darwin-x64/update-v8-snapshot-cache-on-develop-b6f93c7fc2cd7226e15b8b2d66de2a4bc58ef581/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on b6f93c7 May 23, 2023

Choose a reason for hiding this comment

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

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.12.1/win32-x64/update-v8-snapshot-cache-on-develop-b6f93c7fc2cd7226e15b8b2d66de2a4bc58ef581/cypress.tgz

Please sign in to comment.