Skip to content

Commit

Permalink
Merge branch '10.0-release' into tgriesser/chore/UNIFY-1256-auto-merg…
Browse files Browse the repository at this point in the history
…e-config

* 10.0-release:
  fix: make error on integration folder point to e2e (#20853)
  fix(unify): Update Cypress Dashboard Service Link in Login Modal (#21084)
  chore: fix windows node_modules install step (#21098)
  fix: webpack integration tests for app w webpack-dev-server-fresh (#21093)
  fix: move non spec files on migration (#21054)
  Bumping electron version in root
  chore(deps): Bumping electron dependency to 15.5.1 (#21072)
  fix: resolves correctly specPattern (#21057)
  feat: replace reconfigure button on settings page with link to config doc (#21077)
  feat(launchpad): update CT setup and config scaffolding (#20893)
  fix: cy.type('{enter}') on <input> elements submits the form correctly after Firefox 98. (#21042)
  chore: making the npm deps for vue, react, and vue2 use 0.0.0-dev (#21081)
  fix(cli): show additional mitigation steps for max path length error (#21047)
  fix: Plugin error when sending on disconnected IPC channel (#21011)
  chore: add internal types for cy.session command (#21028)
  chore: Update Chrome (stable) to 100.0.4896.88 (#21043)
  • Loading branch information
tgriesser committed Apr 18, 2022
2 parents 7bd810c + 026c300 commit e1a4b3d
Show file tree
Hide file tree
Showing 59 changed files with 623 additions and 193 deletions.
2 changes: 1 addition & 1 deletion browser-versions.json
@@ -1,4 +1,4 @@
{
"chrome:beta": "101.0.4951.26",
"chrome:stable": "100.0.4896.75"
"chrome:stable": "100.0.4896.88"
}
11 changes: 10 additions & 1 deletion circle.yml
Expand Up @@ -31,6 +31,14 @@ mainBuildFilters: &mainBuildFilters
- 10.0-release
- unify-1449-check-path-length-in-build

# uncomment & add to the branch conditions below to disable the main linux
# flow if we don't want to test it for a certain branch
linuxWorkflowExcludeFilters: &linux-workflow-exclude-filters
unless:
or:
- false
# - equal: [ 'tgriesser/chore/fix-windows-build', << pipeline.git.branch >> ]

# usually we don't build Mac app - it takes a long time
# but sometimes we want to really confirm we are doing the right thing
# so just add your branch to the list here to build and test on Mac
Expand All @@ -49,7 +57,7 @@ windowsWorkflowFilters: &windows-workflow-filters
or:
- equal: [ develop, << pipeline.git.branch >> ]
- equal: [ '10.0-release', << pipeline.git.branch >> ]
- equal: [ unify-1449-check-path-length-in-build, << pipeline.git.branch >> ]
- equal: [ 'tgriesser/chore/fix-windows-build', << pipeline.git.branch >> ]
- matches:
pattern: "-release$"
value: << pipeline.git.branch >>
Expand Down Expand Up @@ -2535,6 +2543,7 @@ windows-workflow: &windows-workflow
workflows:
linux:
<<: *linux-workflow
<<: *linux-workflow-exclude-filters
mac:
<<: *mac-workflow
<<: *mac-workflow-filters
Expand Down
1 change: 1 addition & 0 deletions cli/__snapshots__/errors_spec.js
Expand Up @@ -79,6 +79,7 @@ exports['errors individual has the following errors 1'] = [
"childProcessKilled",
"failedDownload",
"failedUnzip",
"failedUnzipWindowsMaxPathLength",
"incompatibleHeadlessFlags",
"incompatibleTestTypeFlags",
"incompatibleTestingTypeAndFlag",
Expand Down
20 changes: 19 additions & 1 deletion cli/__snapshots__/unzip_spec.js
@@ -1,4 +1,4 @@
exports['unzip error 1'] = `
exports['lib/tasks/unzip throws when cannot unzip 1'] = `
Error: The Cypress App could not be unzipped.
Search for an existing issue or open a GitHub issue at
Expand All @@ -15,3 +15,21 @@ Platform: darwin-x64 (Foo-OsVersion)
Cypress Version: 1.2.3
`

exports['lib/tasks/unzip throws max path length error when cannot unzip due to realpath ENOENT on windows 1'] = `
Error: The Cypress App could not be unzipped.
This is most likely because the maximum path length is being exceeded on your system.
Read here for solutions to this problem: https://on.cypress.io/win-max-path-length-error
----------
Error: failed
----------
Platform: win32-x64 (Foo-OsVersion)
Cypress Version: 1.2.3
`
8 changes: 8 additions & 0 deletions cli/lib/errors.js
Expand Up @@ -58,6 +58,13 @@ const failedUnzip = {
solution: genericErrorSolution,
}

const failedUnzipWindowsMaxPathLength = {
description: 'The Cypress App could not be unzipped.',
solution: `This is most likely because the maximum path length is being exceeded on your system.
Read here for solutions to this problem: https://on.cypress.io/win-max-path-length-error`,
}

const missingApp = (binaryDir) => {
return {
description: `No version of Cypress is installed in: ${chalk.cyan(
Expand Down Expand Up @@ -419,6 +426,7 @@ module.exports = {
unexpected,
failedDownload,
failedUnzip,
failedUnzipWindowsMaxPathLength,
invalidCypressEnv,
invalidCacheDirectory,
CYPRESS_RUN_BINARY,
Expand Down
29 changes: 19 additions & 10 deletions cli/lib/tasks/unzip.js
Expand Up @@ -195,26 +195,35 @@ const unzip = ({ zipFilePath, installDir, progress }) => {
})
}

const start = ({ zipFilePath, installDir, progress }) => {
function isMaybeWindowsMaxPathLengthError (err) {
return os.platform() === 'win32' && err.code === 'ENOENT' && err.syscall === 'realpath'
}

const start = async ({ zipFilePath, installDir, progress }) => {
la(is.unemptyString(installDir), 'missing installDir')
if (!progress) {
progress = { onProgress: () => {
return {}
} }
}

return fs.pathExists(installDir)
.then((exists) => {
if (exists) {
try {
const installDirExists = await fs.pathExists(installDir)

if (installDirExists) {
debug('removing existing unzipped binary', installDir)

return fs.removeAsync(installDir)
await fs.removeAsync(installDir)
}
})
.then(() => {
return unzip({ zipFilePath, installDir, progress })
})
.catch(throwFormErrorText(errors.failedUnzip))

await unzip({ zipFilePath, installDir, progress })
} catch (err) {
const errorTemplate = isMaybeWindowsMaxPathLengthError(err) ?
errors.failedUnzipWindowsMaxPathLength
: errors.failedUnzip

await throwFormErrorText(errorTemplate)(err)
}
}

module.exports = {
Expand Down
2 changes: 2 additions & 0 deletions cli/scripts/post-install.js
Expand Up @@ -25,6 +25,8 @@ fs.ensureDirSync(join(__dirname, '..', 'types'))
includeTypes.forEach((folder) => {
const source = resolvePkg(`@types/${folder}`, { cwd: __dirname })

console.log(`copying ${folder} from ${source}`)

fs.copySync(source, join(__dirname, '..', 'types', folder))
})

Expand Down
46 changes: 32 additions & 14 deletions cli/test/lib/tasks/unzip_spec.js
Expand Up @@ -30,26 +30,44 @@ describe('lib/tasks/unzip', function () {

afterEach(function () {
stdout.restore()
})

it('throws when cannot unzip', async function () {
try {
await unzip.start({
zipFilePath: path.join('test', 'fixture', 'bad_example.zip'),
installDir,
})
} catch (err) {
logger.error(err)

// return fs.removeAsync(installationDir)
return snapshot(normalize(this.stdout.toString()))
}

throw new Error('should have failed')
})

it('throws when cannot unzip', function () {
const ctx = this
it('throws max path length error when cannot unzip due to realpath ENOENT on windows', async function () {
const err = new Error('failed')

return unzip
.start({
zipFilePath: path.join('test', 'fixture', 'bad_example.zip'),
installDir,
})
.then(() => {
throw new Error('should have failed')
})
.catch((err) => {
err.code = 'ENOENT'
err.syscall = 'realpath'

os.platform.returns('win32')
sinon.stub(fs, 'ensureDirAsync').rejects(err)

try {
await unzip.start({
zipFilePath: path.join('test', 'fixture', 'bad_example.zip'),
installDir,
})
} catch (err) {
logger.error(err)

snapshot('unzip error 1', normalize(ctx.stdout.toString()))
})
return snapshot(normalize(this.stdout.toString()))
}

throw new Error('should have failed')
})

it('can really unzip', function () {
Expand Down
2 changes: 1 addition & 1 deletion npm/react/package.json
Expand Up @@ -21,7 +21,6 @@
"watch": "yarn build --watch --watch.exclude ./dist/**/*"
},
"dependencies": {
"@cypress/mount-utils": "file:../mount-utils",
"debug": "^4.3.2",
"find-webpack": "2.2.1",
"find-yarn-workspace-root": "2.0.0"
Expand All @@ -37,6 +36,7 @@
"@bahmutov/cy-api": "1.4.2",
"@bahmutov/cy-rollup": "2.0.0",
"@cypress/code-coverage": "3.9.4",
"@cypress/mount-utils": "0.0.0-development",
"@cypress/webpack-dev-server": "0.0.0-development",
"@date-io/date-fns": "1",
"@emotion/babel-preset-css-prop": "10.0.27",
Expand Down
3 changes: 3 additions & 0 deletions npm/vite-dev-server-fresh/cypress.config.ts
Expand Up @@ -19,6 +19,9 @@ export default defineConfig({
return await e2ePluginSetup(on, config)
},
},
retries: {
runMode: 2,
},
// @ts-ignore We are setting these namespaces in order to properly test Cypress in Cypress
clientRoute: '/__app/',
namespace: '__cypress-app',
Expand Down
2 changes: 1 addition & 1 deletion npm/vue/package.json
Expand Up @@ -16,7 +16,6 @@
"test:ci:ct": "node ../../scripts/run-ct-examples.js --examplesList=./examples.env"
},
"dependencies": {
"@cypress/mount-utils": "file:../mount-utils",
"@vue/test-utils": "2.0.0-rc.19"
},
"devDependencies": {
Expand All @@ -25,6 +24,7 @@
"@babel/preset-env": "7.9.5",
"@babel/preset-typescript": "7.10.1",
"@cypress/code-coverage": "3.8.1",
"@cypress/mount-utils": "0.0.0-development",
"@cypress/webpack-dev-server": "0.0.0-development",
"@intlify/vue-i18n-loader": "2.0.0-rc.1",
"@rollup/plugin-commonjs": "^17.1.0",
Expand Down
2 changes: 1 addition & 1 deletion npm/vue2/package.json
Expand Up @@ -13,10 +13,10 @@
"test-ci": "node ../../scripts/run-ct-examples.js --examplesList=./examples.env"
},
"dependencies": {
"@cypress/mount-utils": "file:../mount-utils",
"@vue/test-utils": "^1.1.3"
},
"devDependencies": {
"@cypress/mount-utils": "0.0.0-development",
"@rollup/plugin-commonjs": "^17.1.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^11.1.1",
Expand Down
3 changes: 3 additions & 0 deletions npm/webpack-dev-server-fresh/cypress.config.ts
Expand Up @@ -17,6 +17,9 @@ export default defineConfig({
return await e2ePluginSetup(on, config)
},
},
retries: {
runMode: 2,
},
// @ts-ignore We are setting these namespaces in order to properly test Cypress in Cypress
clientRoute: '/__app/',
namespace: '__cypress-app',
Expand Down
3 changes: 1 addition & 2 deletions npm/webpack-dev-server-fresh/package.json
Expand Up @@ -20,9 +20,8 @@
"dependencies": {
"html-webpack-plugin-4": "npm:html-webpack-plugin@^4",
"html-webpack-plugin-5": "npm:html-webpack-plugin@^5",
"rimraf": "3.0.2",
"speed-measure-webpack-plugin": "1.4.2",
"tsutils": "^3.21.0",
"tslib": "^2.3.1",
"webpack-dev-server": "^4.7.4",
"webpack-merge": "^5.4.0"
},
Expand Down
@@ -1,6 +1,9 @@
import Module from 'module'
import path from 'path'
import type { WebpackDevServerConfig } from '../devServer'
import debugFn from 'debug'

const debug = debugFn('cypress:webpack-dev-server-fresh:sourceRelativeWebpackModules')

type ModuleClass = typeof Module & {
_load(id: string, parent: Module, isMain: boolean): any
Expand Down Expand Up @@ -68,13 +71,20 @@ export function sourceRelativeWebpackModules (config: WebpackDevServerConfig) {

// First, we source the framework, ensuring it's sourced from the user's project and not the
// Cypress binary. This is the path we use to relative-resolve the
// This is generally used for Create React App and Vue CLI and other packages
// that ship webpack as a dependency. e.g. your-project/node_modules/react-scripts/node_modules/webpack
// So what we do, is we grab the framework's path, and try and find webpack relative to that framework.
if (config.framework) {
try {
const frameworkJsonPath = require.resolve(`${config.framework}/package.json`, {
paths: [searchRoot],
})

debug('Framework JSON path is %s', frameworkJsonPath)
const frameworkPathRoot = path.dirname(frameworkJsonPath)

debug('Framework JSON path root is %s', frameworkPathRoot)

// Want to make sure we're sourcing this from the user's code. Otherwise we can
// warn and tell them they don't have their dependencies installed
if (!frameworkPathRoot.includes(config.cypressConfig.cypressBinaryRoot)) {
Expand All @@ -86,14 +96,18 @@ export function sourceRelativeWebpackModules (config: WebpackDevServerConfig) {
searchRoot = frameworkPathRoot
}
} catch (e) {
debug('Error %o', e)
// TODO
}
}

// Webpack:

// At this point, we know where we're looking for webpack!
// We've made accommodations for certain frameworks that bundle it in (e.g. react-scripts)
let webpackJsonPath: string

debug('search root is %s', searchRoot)

try {
webpackJsonPath = require.resolve('webpack/package.json', {
paths: [searchRoot],
Expand All @@ -110,19 +124,25 @@ export function sourceRelativeWebpackModules (config: WebpackDevServerConfig) {
}),
],
})

debug('using webpack-batteries-included %s', webpackJsonPath)
}

result.webpack.importPath = path.dirname(webpackJsonPath)
result.webpack.packageJson = require(webpackJsonPath)
result.webpack.module = require(result.webpack.importPath)
result.webpack.majorVersion = getMajorVersion(result.webpack.packageJson, [4, 5]);
result.webpack.majorVersion = getMajorVersion(result.webpack.packageJson, [4, 5])

const webpackImportPath = result.webpack.importPath

(Module as ModuleClass)._load = function (request, parent, isMain) {
;(Module as ModuleClass)._load = function (request, parent, isMain) {
if (request === 'webpack' || request.startsWith('webpack/')) {
const resolvePath = require.resolve(request, {
paths: [searchRoot],
paths: [webpackImportPath],
})

debug('Resolve path %s', resolvePath)

return originalModuleLoad(resolvePath, parent, isMain)
}

Expand All @@ -132,7 +152,7 @@ export function sourceRelativeWebpackModules (config: WebpackDevServerConfig) {
(Module as ModuleClass)._resolveFilename = function (request, parent, isMain, options) {
if (request === 'webpack' || request.startsWith('webpack/') && !options?.paths) {
return originalModuleResolveFilename(request, parent, isMain, {
paths: [searchRoot],
paths: [webpackImportPath],
})
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -146,7 +146,7 @@
"dedent": "^0.7.0",
"del": "3.0.0",
"detect-port": "^1.3.0",
"electron": "15.3.5",
"electron": "15.5.1",
"electron-builder": "^22.13.1",
"electron-notarize": "^1.1.1",
"enzyme-adapter-react-16": "1.12.1",
Expand Down

0 comments on commit e1a4b3d

Please sign in to comment.