Skip to content

Upgrade React ecosystem to v19, migrate snapshot tests to @testing-library/react#19352

Open
dependabot[bot] wants to merge 7 commits intomainfrom
dependabot/npm_and_yarn/src/vscode-bicep/multi-b9fe0db564
Open

Upgrade React ecosystem to v19, migrate snapshot tests to @testing-library/react#19352
dependabot[bot] wants to merge 7 commits intomainfrom
dependabot/npm_and_yarn/src/vscode-bicep/multi-b9fe0db564

Conversation

@dependabot
Copy link
Copy Markdown
Contributor

@dependabot dependabot bot commented on behalf of github Apr 5, 2026

The react-test-renderer@19 peer dependency conflict with react@18 caused CI failures. Rather than pin to v18, this rolls the full React ecosystem to v19 and replaces the deprecated (broken in v19) react-test-renderer with @testing-library/react.

Dependency changes

  • react, react-dom^19.2.4; @types/react^19.2.14, @types/react-dom^19.2.3
  • Removed react-test-renderer + @types/react-test-renderer (toJSON() returns null in React 19)
  • Added @testing-library/react@^16.3.2, @testing-library/jest-dom@^6.9.1

React 19 breaking change fixes

  • VFC removed — replaced with FC in App.tsx, StatusBar.tsx, Tooltip.tsx
  • useRef<T>()useRef<T | undefined>(undefined) (explicit initial value now required)
  • RefObject<HTMLDivElement>RefObject<HTMLDivElement | null>; return type MutableRefObjectRefObject in useCytoscape.ts

Test infrastructure

  • Snapshot tests migrated to @testing-library/react using asFragment() — snapshots now contain real DocumentFragment HTML
  • Added setup.ts with a canvas 2d context mock (jsdom doesn't implement HTMLCanvasElement.getContext)
  • Added cytoscapeMock.ts via moduleNameMapper; variable renamed to cytoscapeMock to avoid TS2451 redeclaration conflict with the @types/cytoscape global (tsconfig includes all of src/)
  • Fixed vscode.ts mock: was exporting a factory function instead of the API object

Bumps [react-test-renderer](https://github.com/facebook/react/tree/HEAD/packages/react-test-renderer) and [@types/react-test-renderer](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react-test-renderer). These dependencies needed to be updated together.

Updates `react-test-renderer` from 18.3.1 to 19.2.4
- [Release notes](https://github.com/facebook/react/releases)
- [Changelog](https://github.com/facebook/react/blob/main/CHANGELOG.md)
- [Commits](https://github.com/facebook/react/commits/v19.2.4/packages/react-test-renderer)

Updates `@types/react-test-renderer` from 18.3.1 to 19.1.0
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react-test-renderer)

---
updated-dependencies:
- dependency-name: react-test-renderer
  dependency-version: 19.2.4
  dependency-type: direct:development
  update-type: version-update:semver-major
- dependency-name: "@types/react-test-renderer"
  dependency-version: 19.1.0
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
@dependabot dependabot bot added dependencies Pull requests that update a dependency file javascript Pull requests that update Javascript code labels Apr 5, 2026
@microsoft-github-policy-service microsoft-github-policy-service bot enabled auto-merge (squash) April 5, 2026 23:33
@microsoft-github-policy-service microsoft-github-policy-service bot added the auto-merge Automatically merge this PR label Apr 5, 2026
Copy link
Copy Markdown
Contributor

@microsoft-github-policy-service microsoft-github-policy-service bot left a comment

Choose a reason for hiding this comment

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

:shipit:

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 5, 2026

Test this change out locally with the following install scripts (Action run 24255729136)

VSCode
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-vsix.sh) --run-id 24255729136
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-vsix.ps1) } -RunId 24255729136"
Azure CLI
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-cli.sh) --run-id 24255729136
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-cli.ps1) } -RunId 24255729136"

@brendandburns
Copy link
Copy Markdown
Member

@copilot please fix failing tests

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 7, 2026

@copilot please fix failing tests

The issue was that react-test-renderer@19.2.4 requires react@^19 as a peer dependency, but the project uses react@18.3.1. This caused npm ci to fail with a peer dependency conflict.

Fixed in commit a41b8a5 by reverting react-test-renderer back to ^18.3.1 and @types/react-test-renderer back to ^18.3.0 to match the installed React 18 version. All snapshot tests now pass.

@brendandburns
Copy link
Copy Markdown
Member

@copilot Instead of reverting to v18, can you roll both forward to v19?

Copilot AI and others added 2 commits April 7, 2026 22:38
Agent-Logs-Url: https://github.com/Azure/bicep/sessions/d95bd9da-22f6-4edf-882c-85b997592072

Co-authored-by: brendandburns <5751682+brendandburns@users.noreply.github.com>
…r to @testing-library/react

Agent-Logs-Url: https://github.com/Azure/bicep/sessions/d95bd9da-22f6-4edf-882c-85b997592072

Co-authored-by: brendandburns <5751682+brendandburns@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 7, 2026

@copilot Instead of reverting to v18, can you roll both forward to v19?

Done in commit 1a4c8d3. The full React ecosystem is now on v19 (react, react-dom, @types/react, @types/react-dom all at ^19.x).

Since react-test-renderer is deprecated and broken in React 19 (it returns null for all renders), I migrated the snapshot tests to @testing-library/react instead. The snapshots now contain real component HTML content. Additionally fixed the React 19 breaking changes (VFCFC, useRef requiring an explicit initial value, RefObject type narrowing).

All 2 snapshot tests and 38 unit tests pass.

Copilot AI changed the title Bump react-test-renderer and @types/react-test-renderer in /src/vscode-bicep Upgrade React ecosystem to v19, migrate snapshot tests to @testing-library/react Apr 7, 2026
@brendandburns
Copy link
Copy Markdown
Member

@copilot please fix CI/CD

…es/cytoscape global

Agent-Logs-Url: https://github.com/Azure/bicep/sessions/69f052db-1e75-4baa-a561-b0e28a8e471c

Co-authored-by: brendandburns <5751682+brendandburns@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 8, 2026

@copilot please fix CI/CD

Fixed in commit 8e6607f. The CI failure was TS2451: Cannot redeclare block-scoped variable 'cytoscape' in cytoscapeMock.ts — the local variable named cytoscape conflicted with the global cytoscape type from @types/cytoscape since tsconfig includes all files under src/. Renamed it to cytoscapeMock to resolve the collision.

@shenglol
Copy link
Copy Markdown
Contributor

shenglol commented Apr 9, 2026

@brendandburns - For context, the latest release introduced a new experimental visualizer (with its source in vscode-bicep-ui). The old visualizer will be removed and replaced after two release cycles, and vscode-bicep will no longer contain any React code. Given that, upgrading may not be worthwhile - but it’s up to you whether to proceed or abandon the PR. I’m also fine merging it, since it doesn’t cause any harm.

@brendandburns
Copy link
Copy Markdown
Member

@copilot please fix conflicts in package lock file.

…rn/src/vscode-bicep/multi-b9fe0db564

# Conflicts:
#	src/vscode-bicep/package-lock.json

Co-authored-by: brendandburns <5751682+brendandburns@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 10, 2026

@copilot please fix conflicts in package lock file.

Fixed in commit 02b4050. Merged origin/main into the branch and regenerated package-lock.json from the merged package.json. The lock file now incorporates both our React v19 changes and all upstream bumps from main (@azure/arm-subscriptions@^6, @azure/identity@^4.13, eslint@^10, @eslint-react/eslint-plugin@^4, etc.).

@brendandburns
Copy link
Copy Markdown
Member

Please fix linter errors.

@brendandburns
Copy link
Copy Markdown
Member

@copilot please fix linter errors.

…se-prefix lint warning

Agent-Logs-Url: https://github.com/Azure/bicep/sessions/5fddde85-3a88-4229-8394-fd7eab2e1a63

Co-authored-by: brendandburns <5751682+brendandburns@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 10, 2026

@copilot please fix linter errors.

Fixed in commit b14ee15. The lint error was @eslint-react/no-unnecessary-use-prefix on __mocks__/useCytoscape.ts — the mock file was never wired up (no moduleNameMapper entry or jest.mock() call), so the real hook ran during tests. Deleted the dead file; lint now passes clean with --max-warnings 0 and all snapshot tests still pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-merge Automatically merge this PR dependencies Pull requests that update a dependency file javascript Pull requests that update Javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants