Skip to content

Conversation

@AtofStryker
Copy link
Contributor

@AtofStryker AtofStryker commented Nov 5, 2025

  • Closes N/A

Additional details

Converts the tests in @cypress/webpack-preprocessor from mocha to vitest. Because this is still a CommonJS module that relies on require() to source the TypeScript location for the consuming user, I needed to introduce mock-require and refactored this code into get-typescript to test this functionality separately. proxyquire isn't an option here as I cannot get it to run in the vitest context (see vitest-dev/vitest#3134). This is only temporary until we move to ESM in this module or replace it.

I also merged the helpers file into the e2e.spec.ts as its the only file that is using this.

Steps to test

How has the user experience changed?

PR Tasks


Note

Migrates @cypress/webpack-preprocessor tests from Mocha to Vitest, adds a get-typescript helper and refactors TS overrides, updates configs/scripts and minor types/ESM tweaks.

  • npm/webpack-preprocessor:
    • Tests → Vitest:
      • Convert unit/e2e tests to Vitest (test/unit/*.spec.ts, test/e2e/*.spec.ts), replace Chai/Sinon/SnapShot with Vitest APIs and snapshots; remove legacy Mocha tests/helpers.
      • Add vitest.config.ts and update snapshots (__snapshots__/compilation.spec.ts.snap).
    • New utility: Add lib/get-typescript.ts and use it in lib/typescript-overrides.ts for resolving the project TypeScript; update tests for it.
    • Preprocessor tweaks:
      • Make WebpackPreprocessorFn options optional; keep CJS export with note for future ESM.
      • Minor cleanup in error handling/types; no functional changes to bundling.
    • Config/Scripts:
      • Update package.json scripts to run Vitest; switch test runner script to TS (scripts/test-webpack-5.ts) and tsx execution; remove Mocha/Chai/Sinon deps; add vitest, strip-ansi, mock-require, TS v5.
      • Convert cypress.config.ts to ESM import/export and simplify preprocessor wiring.
  • Docs:
    • Update guides/esm-migration.md checklist to mark npm/webpack-preprocessor as completed in Phase 2.

Written by Cursor Bugbot for commit 9665122. This will update automatically on new commits. Configure here.

@AtofStryker AtofStryker force-pushed the chore/webpack-preprocessor-vitest branch from 17ae6aa to c13e66c Compare November 5, 2025 21:48
@AtofStryker AtofStryker force-pushed the chore/webpack-preprocessor-vitest branch from c13e66c to 3e073ee Compare November 5, 2025 21:53
@AtofStryker AtofStryker force-pushed the chore/webpack-preprocessor-vitest branch 4 times, most recently from a3472ff to 1ebe107 Compare November 6, 2025 14:33
@cypress
Copy link

cypress bot commented Nov 6, 2025

cypress    Run #67208

Run Properties:  status check failed Failed #67208  •  git commit 96651221e1: chore: fix unit tests
Project cypress
Branch Review chore/webpack-preprocessor-vitest
Run status status check failed Failed #67208
Run duration 17m 11s
Commit git commit 96651221e1: chore: fix unit tests
Committer Bill Glesias
View all properties for this run ↗︎

Test results
Tests that failed  Failures 1
Tests that were flaky  Flaky 2
Tests that did not run due to a developer annotating a test with .skip  Pending 132
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 6245
View all changes introduced in this branch ↗︎
UI Coverage  38.03%
  Untested elements 132  
  Tested elements 81  
Accessibility  97.39%
  Failed rules  3 critical   7 serious   1 moderate   1 minor
  Failed elements 62  

Tests for review

Failed  cypress/e2e/commands/files.cy.js • 1 failed test • 5x-driver-firefox

View Output

Test Artifacts
src/cy/commands/files > #readFile > retries to read when ENOENT
    </td>
  </tr></table>
Flakiness  commands/net_stubbing.cy.ts • 1 flaky test • 5x-driver-firefox

View Output

Test Artifacts
... > stops waiting when an xhr request is canceled
    </td>
  </tr></table>
Flakiness  issues/28527.cy.ts • 1 flaky test • 5x-driver-firefox

View Output

Test Artifacts
issue 28527 > fails and then retries and verifies about:blank is not displayed Screenshots

@AtofStryker AtofStryker force-pushed the chore/webpack-preprocessor-vitest branch from 498b424 to a0c2cb2 Compare November 6, 2025 16:02
@AtofStryker AtofStryker self-assigned this Nov 6, 2025
@AtofStryker AtofStryker changed the title chore(draft): convert webpack-preprocessor tests to vitest misc(draft): convert webpack-preprocessor tests to vitest Nov 6, 2025
@AtofStryker AtofStryker changed the title misc(draft): convert webpack-preprocessor tests to vitest misc: convert webpack-preprocessor tests to vitest Nov 6, 2025
@jennifer-shehane jennifer-shehane self-requested a review November 6, 2025 20:29
@AtofStryker AtofStryker force-pushed the chore/webpack-preprocessor-vitest branch from 5404723 to 9665122 Compare November 7, 2025 13:44
logs.push(str)
if (passThrough) {
return write.apply(this, [passThrough(str)])
}
Copy link

Choose a reason for hiding this comment

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

Bug: WriteStream.write: missing return value breaks backpressure

The stdio.write override doesn't return a value when passThrough is falsy, but Node.js WriteStream.write() must return a boolean indicating whether the write was successful. This can cause issues with backpressure handling and may break code that checks the return value.

Fix in Cursor Fix in Web

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this isn't relevant

@AtofStryker AtofStryker merged commit a5a0dae into develop Nov 7, 2025
87 of 92 checks passed
@AtofStryker AtofStryker deleted the chore/webpack-preprocessor-vitest branch November 7, 2025 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants