-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[DRAFT] feat: bun support #32580
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
base: develop
Are you sure you want to change the base?
[DRAFT] feat: bun support #32580
Changes from all commits
33554fc
aab825f
8092da8
cdb9df3
8c13520
4a7b8e4
e1529cf
a2f0f17
64f7166
3c6bcc5
340ccca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| # Bump this version to force CI to re-create the cache from scratch. | ||
| 10-17-2025 | ||
| 12-1-2025 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1689,6 +1689,7 @@ enum OverLimitActionTypeEnum { | |
| } | ||
|
|
||
| enum PackageManagerEnum { | ||
| bun | ||
| npm | ||
| pnpm | ||
| yarn | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import path from 'path' | ||
| import tempDir from 'temp-dir' | ||
| import { homedir } from 'os' | ||
|
|
||
| export function getBunCommand (opts: { | ||
| updateLockFile: boolean | ||
| isCI: boolean | ||
| runScripts: boolean | ||
| }): { cmd: string, env?: Record<string, string> } { | ||
| let cmd = 'bun install' | ||
|
|
||
| if (!opts.runScripts) cmd += ' --ignore-scripts' | ||
|
|
||
| if (!opts.updateLockFile) cmd += ' --frozen-lockfile' | ||
|
|
||
| // Bun configures cache directory via BUN_INSTALL_CACHE_DIR environment variable, not a flag | ||
| const cacheDir = opts.isCI | ||
| ? path.join(homedir(), '.bun', 'install', 'cache') | ||
| : path.join(tempDir, 'cy-system-tests-bun-cache', String(Date.now())) | ||
|
|
||
| return { | ||
| cmd, | ||
| env: { | ||
| BUN_INSTALL_CACHE_DIR: cacheDir, | ||
| }, | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import path from 'path' | ||
| import tempDir from 'temp-dir' | ||
| import { homedir } from 'os' | ||
|
|
||
| export function getPnpmCommand (opts: { | ||
| yarnV311: boolean | ||
| updateLockFile: boolean | ||
| isCI: boolean | ||
| runScripts: boolean | ||
| }): string { | ||
| let cmd = 'pnpm install' | ||
|
|
||
| if (opts.yarnV311) throw new Error('_cyYarnV311 is not supported with PNPM.') | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Irrelevant Parameter Causes Command FailuresThe Additional Locations (1) |
||
|
|
||
| if (!opts.runScripts) cmd += ' --ignore-scripts' | ||
|
|
||
| if (!opts.updateLockFile) cmd += ' --frozen-lockfile' | ||
|
|
||
| if (opts.isCI) cmd += ` --store-dir=${homedir()}/.pnpm-store` | ||
| else cmd += ` --store-dir=${path.join(tempDir, 'cy-system-tests-pnpm-store', String(Date.now()))}` | ||
|
|
||
| return cmd | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { defineConfig } from 'cypress' | ||
|
|
||
| export default defineConfig({ | ||
| component: { | ||
| devServer: { | ||
| framework: 'react', | ||
| bundler: 'webpack', | ||
| }, | ||
| }, | ||
| e2e: { | ||
| baseUrl: 'http://localhost:5000', | ||
| }, | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import React from 'react' | ||
| import { mount } from '@cypress/react' | ||
|
|
||
| describe('Bun Component Test', () => { | ||
| it('should render a simple React component', () => { | ||
| const TestComponent = () => ( | ||
| <div> | ||
| <h1>Hello from Bun!</h1> | ||
| <p>This component is tested using Bun package manager</p> | ||
| </div> | ||
| ) | ||
|
|
||
| mount(<TestComponent />) | ||
| cy.contains('Hello from Bun!').should('be.visible') | ||
| cy.contains('This component is tested using Bun package manager').should('be.visible') | ||
| }) | ||
|
|
||
| it('should work with TypeScript', () => { | ||
| interface Props { | ||
| message: string | ||
| } | ||
|
|
||
| const TypeScriptComponent: React.FC<Props> = ({ message }) => ( | ||
| <div> | ||
| <h2>TypeScript Component</h2> | ||
| <p>{message}</p> | ||
| </div> | ||
| ) | ||
|
|
||
| mount(<TypeScriptComponent message="Bun + TypeScript + Cypress" />) | ||
| cy.contains('TypeScript Component').should('be.visible') | ||
| cy.contains('Bun + TypeScript + Cypress').should('be.visible') | ||
| }) | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "target": "es5", | ||
| "lib": ["dom", "dom.iterable", "es6"], | ||
| "allowJs": true, | ||
| "skipLibCheck": true, | ||
| "esModuleInterop": true, | ||
| "allowSyntheticDefaultImports": true, | ||
| "strict": true, | ||
| "forceConsistentCasingInFileNames": true, | ||
| "module": "esnext", | ||
| "moduleResolution": "node", | ||
| "resolveJsonModule": true, | ||
| "isolatedModules": true, | ||
| "noEmit": true, | ||
| "jsx": "react-jsx" | ||
| }, | ||
| "include": [ | ||
| "**/*" | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "name": "bun-component-testing", | ||
| "version": "0.0.0-test", | ||
| "dependencies": { | ||
| "react": "^18.2.0", | ||
| "react-dom": "^18.2.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/react": "^18.2.0", | ||
| "@types/react-dom": "^18.2.0", | ||
| "typescript": "^5.6.3" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "target": "es5", | ||
| "lib": ["dom", "dom.iterable", "es6"], | ||
| "allowJs": true, | ||
| "skipLibCheck": true, | ||
| "esModuleInterop": true, | ||
| "allowSyntheticDefaultImports": true, | ||
| "strict": true, | ||
| "forceConsistentCasingInFileNames": true, | ||
| "module": "esnext", | ||
| "moduleResolution": "node", | ||
| "resolveJsonModule": true, | ||
| "isolatedModules": true, | ||
| "noEmit": true, | ||
| "jsx": "react-jsx" | ||
| }, | ||
| "include": [ | ||
| "cypress/**/*" | ||
| ] | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| describe('Bun E2E Test', () => { | ||
| it('should work with bun package manager', () => { | ||
| cy.visit('/cypress/fixtures/bun-test.html') | ||
| cy.contains('Bun Test Page').should('be.visible') | ||
| }) | ||
|
|
||
| it('should be able to use lodash imported via bun', () => { | ||
| // This test verifies that dependencies installed via bun are available | ||
| const _ = require('lodash') | ||
|
|
||
| expect(_.isArray).to.be.a('function') | ||
| expect(_.isArray([])).to.be.true | ||
| expect(_.isArray({})).to.be.false | ||
| }) | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <title>Bun Test Page</title> | ||
| </head> | ||
| <body> | ||
| <h1>Bun Test Page</h1> | ||
| <p>This page is used for testing Bun package manager integration with Cypress.</p> | ||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "name": "bun-with-deps", | ||
| "version": "0.0.0-test", | ||
| "dependencies": { | ||
| "lodash": "^4.17.21" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/lodash": "^4.14.225", | ||
| "typescript": "^5.6.3" | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Missing Parameter Causes TypeScript Error
The
getBunCommandfunction's signature doesn't include theyarnV311parameter, which is passed by the caller. This causes a TypeScript compilation error. It also silently ignores the_cyYarnV311flag, unlike other package managers that explicitly error when this unsupported option is present.Additional Locations (1)
system-tests/lib/dep-installer/index.ts#L244-L250