From 8692756b5436d8b17783e1f9f3d73308919a9a8a Mon Sep 17 00:00:00 2001 From: Bill Glesias Date: Fri, 3 Oct 2025 14:34:29 -0400 Subject: [PATCH 1/5] chore: convert tests to vitest --- packages/icons/package.json | 10 +++++----- packages/icons/test/icons.spec.ts | 18 ++++++++++++++++++ packages/icons/test/icons_spec.ts | 18 ------------------ packages/icons/vitest.config.ts | 9 +++++++++ 4 files changed, 32 insertions(+), 23 deletions(-) create mode 100644 packages/icons/test/icons.spec.ts delete mode 100644 packages/icons/test/icons_spec.ts create mode 100644 packages/icons/vitest.config.ts diff --git a/packages/icons/package.json b/packages/icons/package.json index 246e3116e1f..ad09a2ed88d 100644 --- a/packages/icons/package.json +++ b/packages/icons/package.json @@ -5,20 +5,20 @@ "private": true, "main": "index.js", "scripts": { - "build": "ts-node ./scripts/build.ts && ts-node ./scripts/ico.ts", + "build": "tsx ./scripts/build.ts && tsx ./scripts/ico.ts", "check-ts": "tsc --noEmit && yarn -s tslint", "lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, .", "test": "yarn test-unit", - "test-unit": "NODE_ENV=test mocha -r @packages/ts/register test/*.ts", + "test-unit": "vitest run", "tslint": "tslint --config ../ts/tslint.json --project ." }, "devDependencies": { "@types/mocha": "^8.0.3", "@types/to-ico": "^1.1.1", - "chai": "^4.2.0", "fs-extra": "9.1.0", - "mocha": "^8.1.3", - "to-ico": "^1.1.5" + "to-ico": "^1.1.5", + "tsx": "^4.19.3", + "vitest": "^3.2.4" }, "files": [ "dist", diff --git a/packages/icons/test/icons.spec.ts b/packages/icons/test/icons.spec.ts new file mode 100644 index 00000000000..3fe8894fb4d --- /dev/null +++ b/packages/icons/test/icons.spec.ts @@ -0,0 +1,18 @@ +import { describe, it, expect } from 'vitest' +import * as icons from '../src/icons' + +const cwd = process.cwd() + +describe('Cypress Icons', function () { + it('returns path to favicon', function () { + expect(icons.getPathToFavicon('favicon-red.ico')).toEqual(`${cwd }/dist/favicon/favicon-red.ico`) + }) + + it('returns path to icon', function () { + expect(icons.getPathToIcon('cypress.icns')).toEqual(`${cwd }/dist/icons/cypress.icns`) + }) + + it('returns path to logo', function () { + expect(icons.getPathToLogo('cypress-bw.png')).toEqual(`${cwd }/dist/logo/cypress-bw.png`) + }) +}) diff --git a/packages/icons/test/icons_spec.ts b/packages/icons/test/icons_spec.ts deleted file mode 100644 index 09622d4c012..00000000000 --- a/packages/icons/test/icons_spec.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { expect } from 'chai' -import * as icons from '../src/icons' - -const cwd = process.cwd() - -describe('Cypress Icons', function () { - it('returns path to favicon', function () { - expect(icons.getPathToFavicon('favicon-red.ico')).to.eq(`${cwd }/dist/favicon/favicon-red.ico`) - }) - - it('returns path to icon', function () { - expect(icons.getPathToIcon('cypress.icns')).to.eq(`${cwd }/dist/icons/cypress.icns`) - }) - - it('returns path to logo', function () { - expect(icons.getPathToLogo('cypress-bw.png')).to.eq(`${cwd }/dist/logo/cypress-bw.png`) - }) -}) diff --git a/packages/icons/vitest.config.ts b/packages/icons/vitest.config.ts new file mode 100644 index 00000000000..1a9a321880f --- /dev/null +++ b/packages/icons/vitest.config.ts @@ -0,0 +1,9 @@ +import { defineConfig } from 'vitest/config' + +export default defineConfig({ + test: { + include: ['test/**/*.spec.ts'], + globals: true, + environment: 'node', + }, +}) From 256342f5e7e099dc36e91e0407d1a2774a0150a8 Mon Sep 17 00:00:00 2001 From: Bill Glesias Date: Fri, 3 Oct 2025 14:50:12 -0400 Subject: [PATCH 2/5] chore: make icons builds from source and remove ts-node entry point to make ESM compatible --- .circleci/src/pipeline/@pipeline.yml | 2 +- guides/esm-migration.md | 4 +--- packages/icons/.eslintignore | 1 + packages/icons/.gitignore | 3 +++ packages/icons/index.d.ts | 1 - packages/icons/index.js | 1 - packages/icons/{src/icons.ts => index.ts} | 2 +- packages/icons/package.json | 11 ++++++++--- packages/icons/test/icons.spec.ts | 2 +- packages/icons/tsconfig.base.json | 13 +++++++++++++ packages/icons/tsconfig.build.json | 6 ------ packages/icons/tsconfig.cjs.json | 8 ++++++++ packages/icons/tsconfig.esm.json | 9 +++++++++ packages/icons/tsconfig.json | 9 --------- yarn.lock | 12 +++++++++++- 15 files changed, 57 insertions(+), 27 deletions(-) create mode 100644 packages/icons/.gitignore delete mode 100644 packages/icons/index.d.ts delete mode 100644 packages/icons/index.js rename packages/icons/{src/icons.ts => index.ts} (91%) create mode 100644 packages/icons/tsconfig.base.json delete mode 100644 packages/icons/tsconfig.build.json create mode 100644 packages/icons/tsconfig.cjs.json create mode 100644 packages/icons/tsconfig.esm.json delete mode 100644 packages/icons/tsconfig.json diff --git a/.circleci/src/pipeline/@pipeline.yml b/.circleci/src/pipeline/@pipeline.yml index 94f58f9c051..b162ba5c52e 100644 --- a/.circleci/src/pipeline/@pipeline.yml +++ b/.circleci/src/pipeline/@pipeline.yml @@ -1786,7 +1786,7 @@ jobs: source ./scripts/ensure-node.sh yarn lerna run types - sanitize-verify-and-store-mocha-results: - expectedResultCount: 10 + expectedResultCount: 9 verify-release-readiness: <<: *defaults diff --git a/guides/esm-migration.md b/guides/esm-migration.md index f3fbae0fd9a..4e969dadcf2 100644 --- a/guides/esm-migration.md +++ b/guides/esm-migration.md @@ -46,9 +46,8 @@ When migrating some of these projects away from the `ts-node` entry [see `@packa - [ ] packages/example - [ ] packages/extension - [ ] packages/frontend-shared **PARTIAL** - entry point is JS -- [ ] packages/https-proxy - higher priority - [x] packages/electron ✅ **COMPLETED** -- [ ] packages/https-proxy **PARTIAL** - entry point is JS +- [ ] packages/https-proxy - higher priority - [x] packages/icons ✅ **COMPLETED** - [x] packages/launcher ✅ **COMPLETED** - [x] packages/launchpad ✅ **COMPLETED** @@ -98,7 +97,6 @@ When migrating some of these projects away from the `ts-node` entry [see `@packa - [ ] packages/extension - [ ] packages/https-proxy - [x] packages/electron ✅ **COMPLETED** -- [ ] packages/https-proxy - [ ] packages/icons - [ ] packages/launcher - [ ] packages/net-stubbing diff --git a/packages/icons/.eslintignore b/packages/icons/.eslintignore index 79afe972da7..e05514df5ce 100644 --- a/packages/icons/.eslintignore +++ b/packages/icons/.eslintignore @@ -1,4 +1,5 @@ **/dist +index.js **/*.d.ts **/package-lock.json **/tsconfig.json diff --git a/packages/icons/.gitignore b/packages/icons/.gitignore new file mode 100644 index 00000000000..62cf98cce8c --- /dev/null +++ b/packages/icons/.gitignore @@ -0,0 +1,3 @@ +**/dist +index.js +index.d.ts \ No newline at end of file diff --git a/packages/icons/index.d.ts b/packages/icons/index.d.ts deleted file mode 100644 index c28237ffe77..00000000000 --- a/packages/icons/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './dist/icons' \ No newline at end of file diff --git a/packages/icons/index.js b/packages/icons/index.js deleted file mode 100644 index 472bf21cc8c..00000000000 --- a/packages/icons/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./dist/icons') diff --git a/packages/icons/src/icons.ts b/packages/icons/index.ts similarity index 91% rename from packages/icons/src/icons.ts rename to packages/icons/index.ts index ef9751143c5..30c6ec4f430 100644 --- a/packages/icons/src/icons.ts +++ b/packages/icons/index.ts @@ -1,6 +1,6 @@ import path from 'path' -const dist = [__dirname, '..', 'dist'] +const dist = [__dirname, 'dist'] function distPath (...args: string[]) { return path.join.apply(path, dist.concat([...args])) diff --git a/packages/icons/package.json b/packages/icons/package.json index ad09a2ed88d..8f0abab8b78 100644 --- a/packages/icons/package.json +++ b/packages/icons/package.json @@ -5,8 +5,12 @@ "private": true, "main": "index.js", "scripts": { - "build": "tsx ./scripts/build.ts && tsx ./scripts/ico.ts", - "check-ts": "tsc --noEmit && yarn -s tslint", + "build": "yarn build-assets && yarn build:cjs && yarn build:esm", + "build-assets": "tsx ./scripts/build.ts && tsx ./scripts/ico.ts", + "build-prod": "yarn build", + "build:cjs": "tsc -p tsconfig.cjs.json", + "build:esm": "tsc -p tsconfig.esm.json", + "check-ts": "tsc -p tsconfig.cjs.json --noEmit && yarn -s tslint -p tsconfig.cjs.json", "lint": "eslint --ext .js,.jsx,.ts,.tsx,.json, .", "test": "yarn test-unit", "test-unit": "vitest run", @@ -17,7 +21,7 @@ "@types/to-ico": "^1.1.1", "fs-extra": "9.1.0", "to-ico": "^1.1.5", - "tsx": "^4.19.3", + "tsx": "^4.20.5", "vitest": "^3.2.4" }, "files": [ @@ -25,6 +29,7 @@ "index.js", "index.d.ts" ], + "types": "index.d.ts", "license": "MIT", "nx": {} } diff --git a/packages/icons/test/icons.spec.ts b/packages/icons/test/icons.spec.ts index 3fe8894fb4d..89ca0434a32 100644 --- a/packages/icons/test/icons.spec.ts +++ b/packages/icons/test/icons.spec.ts @@ -1,5 +1,5 @@ import { describe, it, expect } from 'vitest' -import * as icons from '../src/icons' +import * as icons from '../index' const cwd = process.cwd() diff --git a/packages/icons/tsconfig.base.json b/packages/icons/tsconfig.base.json new file mode 100644 index 00000000000..ff32cf6ecac --- /dev/null +++ b/packages/icons/tsconfig.base.json @@ -0,0 +1,13 @@ +{ + "include": [ + "index.ts" + ], + "compilerOptions": { + "allowJs": false, + "noImplicitAny": true, + "noUncheckedIndexedAccess": true, + "skipLibCheck": true, + "esModuleInterop": true, + "declaration": true + } +} diff --git a/packages/icons/tsconfig.build.json b/packages/icons/tsconfig.build.json deleted file mode 100644 index e177dd467ba..00000000000 --- a/packages/icons/tsconfig.build.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "./tsconfig.json", - "files": [ - "./src/icons.ts" - ] -} \ No newline at end of file diff --git a/packages/icons/tsconfig.cjs.json b/packages/icons/tsconfig.cjs.json new file mode 100644 index 00000000000..74b2c666914 --- /dev/null +++ b/packages/icons/tsconfig.cjs.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "target": "ES2022", + "module": "CommonJS", + "moduleResolution": "node" + } +} \ No newline at end of file diff --git a/packages/icons/tsconfig.esm.json b/packages/icons/tsconfig.esm.json new file mode 100644 index 00000000000..8bd45b6d560 --- /dev/null +++ b/packages/icons/tsconfig.esm.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "target": "ES2022", + "module": "ES2022", + "moduleResolution": "node", + "noEmit": true + } +} \ No newline at end of file diff --git a/packages/icons/tsconfig.json b/packages/icons/tsconfig.json deleted file mode 100644 index 315454e205a..00000000000 --- a/packages/icons/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "../ts/tsconfig.json", - "compilerOptions": { - "allowJs": false, - "noImplicitAny": true, - "noUncheckedIndexedAccess": true, - "outDir": "dist", - }, -} diff --git a/yarn.lock b/yarn.lock index 6ac4e67f682..c9288e08c76 100644 --- a/yarn.lock +++ b/yarn.lock @@ -24031,7 +24031,7 @@ mocha@7.2.0, mocha@^7.1.0: yargs-parser "13.1.2" yargs-unparser "1.6.0" -mocha@^8.1.1, mocha@^8.1.3: +mocha@^8.1.1: version "8.3.1" resolved "https://registry.yarnpkg.com/mocha/-/mocha-8.3.1.tgz#b9eda6da1eb8cb8d29860a9c2205de5b8a076560" integrity sha512-5SBMxANWqOv5bw3Hx+HVgaWlcWcFEQDUdaUAr1AUU+qwtx6cowhn7gEDT/DwQP7uYxnvShdUOVLbTYAHOEGfDQ== @@ -31953,6 +31953,16 @@ tsx@4.20.5: optionalDependencies: fsevents "~2.3.3" +tsx@^4.20.5: + version "4.20.6" + resolved "https://registry.yarnpkg.com/tsx/-/tsx-4.20.6.tgz#8fb803fd9c1f70e8ccc93b5d7c5e03c3979ccb2e" + integrity sha512-ytQKuwgmrrkDTFP4LjR0ToE2nqgy886GpvRSpU0JAnrdBYppuY5rLkRUYPU1yCryb24SsKBTL/hlDQAEFVwtZg== + dependencies: + esbuild "~0.25.0" + get-tsconfig "^4.7.5" + optionalDependencies: + fsevents "~2.3.3" + tuf-js@^2.2.1: version "2.2.1" resolved "https://registry.npmjs.org/tuf-js/-/tuf-js-2.2.1.tgz#fdd8794b644af1a75c7aaa2b197ddffeb2911b56" From dbf011db3d0c7f68b2a83e37465a8bba1d92bd35 Mon Sep 17 00:00:00 2001 From: Bill Glesias Date: Mon, 6 Oct 2025 11:01:43 -0400 Subject: [PATCH 3/5] make sure the icons tests actually run in CI --- .circleci/src/pipeline/@pipeline.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/src/pipeline/@pipeline.yml b/.circleci/src/pipeline/@pipeline.yml index b162ba5c52e..94f58f9c051 100644 --- a/.circleci/src/pipeline/@pipeline.yml +++ b/.circleci/src/pipeline/@pipeline.yml @@ -1786,7 +1786,7 @@ jobs: source ./scripts/ensure-node.sh yarn lerna run types - sanitize-verify-and-store-mocha-results: - expectedResultCount: 9 + expectedResultCount: 10 verify-release-readiness: <<: *defaults diff --git a/package.json b/package.json index b21b84e3edf..7d3097ad50f 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "stop-only": "npx stop-only --skip .cy,.publish,.projects,node_modules,dist,dist-test,fixtures,lib,bower_components,src,__snapshots__,patches --exclude cypress-tests.ts,*only.cy.js", "stop-only-all": "yarn stop-only --folder packages", "pretest": "yarn ensure-deps", - "test": "yarn lerna exec yarn test --scope=cypress --scope=@packages/{config,data-context,driver,electron,errors,extension,https-proxy,launcher,net-stubbing,network,packherd-require,proxy,rewriter,scaffold-config,socket,v8-snapshot-require,telemetry,stderr-filtering,types} --scope=@tooling/{electron-mksnapshot,v8-snapshot}", + "test": "yarn lerna exec yarn test --scope=cypress --scope=@packages/{config,data-context,driver,electron,errors,extension,https-proxy,icons,launcher,net-stubbing,network,packherd-require,proxy,rewriter,scaffold-config,socket,v8-snapshot-require,telemetry,stderr-filtering,types} --scope=@tooling/{electron-mksnapshot,v8-snapshot}", "test-debug": "lerna exec yarn test-debug --ignore=@packages/{driver,root,static,web-config}", "test-integration": "lerna exec yarn test-integration --ignore=@packages/{driver,root,static,web-config}", "test-mocha": "mocha --reporter spec scripts/spec.js", From 3cf811e60c1a623a499b973a1140df7d5e4d10f7 Mon Sep 17 00:00:00 2001 From: Bill Glesias Date: Mon, 6 Oct 2025 11:28:02 -0400 Subject: [PATCH 4/5] correctly configure ES Module for packages/icons --- packages/icons/.eslintignore | 2 ++ packages/icons/.gitignore | 4 +++- packages/icons/index.mts | 19 +++++++++++++++++++ packages/icons/package.json | 1 + packages/icons/test/icons.spec.ts | 12 ++++++++---- packages/icons/tsconfig.base.json | 3 --- packages/icons/tsconfig.cjs.json | 3 +++ packages/icons/tsconfig.esm.json | 3 +++ 8 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 packages/icons/index.mts diff --git a/packages/icons/.eslintignore b/packages/icons/.eslintignore index e05514df5ce..90b920802dc 100644 --- a/packages/icons/.eslintignore +++ b/packages/icons/.eslintignore @@ -1,6 +1,8 @@ **/dist index.js +index.mjs **/*.d.ts +**/*.d.mts **/package-lock.json **/tsconfig.json **/cypress/fixtures \ No newline at end of file diff --git a/packages/icons/.gitignore b/packages/icons/.gitignore index 62cf98cce8c..d6218f48241 100644 --- a/packages/icons/.gitignore +++ b/packages/icons/.gitignore @@ -1,3 +1,5 @@ **/dist index.js -index.d.ts \ No newline at end of file +index.mjs +index.d.ts +index.d.mts \ No newline at end of file diff --git a/packages/icons/index.mts b/packages/icons/index.mts new file mode 100644 index 00000000000..f565ef8050c --- /dev/null +++ b/packages/icons/index.mts @@ -0,0 +1,19 @@ +import path from 'path' + +const dist = [import.meta.dirname, 'dist'] + +function distPath (...args: string[]) { + return path.join.apply(path, dist.concat([...args])) +} + +export const getPathToFavicon = (filename: string) => { + return distPath('favicon', filename) +} + +export const getPathToIcon = (filename: string) => { + return distPath('icons', filename) +} + +export const getPathToLogo = (filename: string) => { + return distPath('logo', filename) +} diff --git a/packages/icons/package.json b/packages/icons/package.json index 8f0abab8b78..29e60a32540 100644 --- a/packages/icons/package.json +++ b/packages/icons/package.json @@ -31,5 +31,6 @@ ], "types": "index.d.ts", "license": "MIT", + "module": "index.mjs", "nx": {} } diff --git a/packages/icons/test/icons.spec.ts b/packages/icons/test/icons.spec.ts index 89ca0434a32..b5f53a4bef8 100644 --- a/packages/icons/test/icons.spec.ts +++ b/packages/icons/test/icons.spec.ts @@ -1,18 +1,22 @@ import { describe, it, expect } from 'vitest' -import * as icons from '../index' +import * as iconsESM from '../index.mjs' +import * as iconsCjs from '../index.js' const cwd = process.cwd() describe('Cypress Icons', function () { it('returns path to favicon', function () { - expect(icons.getPathToFavicon('favicon-red.ico')).toEqual(`${cwd }/dist/favicon/favicon-red.ico`) + expect(iconsESM.getPathToFavicon('favicon-red.ico')).toEqual(`${cwd }/dist/favicon/favicon-red.ico`) + expect(iconsCjs.getPathToFavicon('favicon-red.ico')).toEqual(`${cwd }/dist/favicon/favicon-red.ico`) }) it('returns path to icon', function () { - expect(icons.getPathToIcon('cypress.icns')).toEqual(`${cwd }/dist/icons/cypress.icns`) + expect(iconsESM.getPathToIcon('cypress.icns')).toEqual(`${cwd }/dist/icons/cypress.icns`) + expect(iconsCjs.getPathToIcon('cypress.icns')).toEqual(`${cwd }/dist/icons/cypress.icns`) }) it('returns path to logo', function () { - expect(icons.getPathToLogo('cypress-bw.png')).toEqual(`${cwd }/dist/logo/cypress-bw.png`) + expect(iconsESM.getPathToLogo('cypress-bw.png')).toEqual(`${cwd }/dist/logo/cypress-bw.png`) + expect(iconsCjs.getPathToLogo('cypress-bw.png')).toEqual(`${cwd }/dist/logo/cypress-bw.png`) }) }) diff --git a/packages/icons/tsconfig.base.json b/packages/icons/tsconfig.base.json index ff32cf6ecac..ea2cb9d4a72 100644 --- a/packages/icons/tsconfig.base.json +++ b/packages/icons/tsconfig.base.json @@ -1,7 +1,4 @@ { - "include": [ - "index.ts" - ], "compilerOptions": { "allowJs": false, "noImplicitAny": true, diff --git a/packages/icons/tsconfig.cjs.json b/packages/icons/tsconfig.cjs.json index 74b2c666914..e335562003d 100644 --- a/packages/icons/tsconfig.cjs.json +++ b/packages/icons/tsconfig.cjs.json @@ -1,5 +1,8 @@ { "extends": "./tsconfig.base.json", + "include": [ + "index.ts" + ], "compilerOptions": { "target": "ES2022", "module": "CommonJS", diff --git a/packages/icons/tsconfig.esm.json b/packages/icons/tsconfig.esm.json index 8bd45b6d560..6bfc1fc875c 100644 --- a/packages/icons/tsconfig.esm.json +++ b/packages/icons/tsconfig.esm.json @@ -1,5 +1,8 @@ { "extends": "./tsconfig.base.json", + "include": [ + "index.mts" + ], "compilerOptions": { "target": "ES2022", "module": "ES2022", From 549af0840e538b8923b9b1ddab8135be097986b3 Mon Sep 17 00:00:00 2001 From: Bill Glesias Date: Mon, 6 Oct 2025 14:40:22 -0400 Subject: [PATCH 5/5] chore: update ESM migration --- guides/esm-migration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/esm-migration.md b/guides/esm-migration.md index 4e969dadcf2..f9b2cd4905a 100644 --- a/guides/esm-migration.md +++ b/guides/esm-migration.md @@ -97,7 +97,7 @@ When migrating some of these projects away from the `ts-node` entry [see `@packa - [ ] packages/extension - [ ] packages/https-proxy - [x] packages/electron ✅ **COMPLETED** -- [ ] packages/icons +- [x] packages/icons ✅ **COMPLETED** - [ ] packages/launcher - [ ] packages/net-stubbing - [x] packages/network ✅ **COMPLETED**