Skip to content

Commit 6ab44fb

Browse files
committed
feat: support React 19
1 parent f4879c6 commit 6ab44fb

File tree

28 files changed

+285
-56
lines changed

28 files changed

+285
-56
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# React 19 Compatibility Test
2+
3+
This directory contains end-to-end tests to verify Gatsby's compatibility with React 19.
4+
5+
## Running the Tests
6+
7+
1. Install dependencies:
8+
9+
```bash
10+
npm install
11+
```
12+
13+
2. Run the tests:
14+
```bash
15+
npm test
16+
```
17+
18+
## Test Cases
19+
20+
1. **Development Server**
21+
22+
- Verifies that the development server starts with React 19
23+
- Tests React 19 state updates and hooks
24+
- Tests error boundaries with React 19
25+
26+
2. **Production Build**
27+
- Verifies that the production build completes successfully with React 19
28+
- Checks for the existence of expected output files
29+
30+
## Dependencies
31+
32+
- React 19.0.0 or later
33+
- React DOM 19.0.0 or later
34+
- Gatsby (linked to local development version)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { defineConfig } from "cypress"
2+
3+
export default defineConfig({
4+
e2e: {
5+
baseUrl: "http://localhost:8000",
6+
supportFile: false,
7+
},
8+
component: {
9+
devServer: {
10+
framework: "create-react-app",
11+
bundler: "webpack",
12+
},
13+
},
14+
})
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/// <reference types="cypress" />
2+
3+
describe("React 19 Compatibility", () => {
4+
beforeEach(() => {
5+
cy.visit("/")
6+
})
7+
8+
it("renders the home page", () => {
9+
cy.get("h1").should("contain", "Gatsby + React 19 Test")
10+
})
11+
12+
it("handles React 19 state updates", () => {
13+
// Initial state
14+
cy.get("p").should("contain", "Count: 0")
15+
16+
// Test state update
17+
cy.get('[data-testid="increment"]').click()
18+
cy.get("p").should("contain", "Count: 1")
19+
})
20+
21+
it("handles React 19 error boundaries", () => {
22+
// Test error boundary
23+
cy.get('[data-testid="error-button"]').click()
24+
cy.get("div").should("contain", "Error: Test error")
25+
})
26+
})
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
siteMetadata: {
3+
title: `Gatsby React 19 Test`,
4+
},
5+
plugins: [],
6+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "gatsby-react-19-compatibility",
3+
"private": true,
4+
"description": "Test React 19 compatibility",
5+
"version": "1.0.0",
6+
"author": "Gatsby Team",
7+
"dependencies": {
8+
"gatsby": "*",
9+
"react": "^19.0.0",
10+
"react-dom": "^19.0.0"
11+
},
12+
"devDependencies": {
13+
"@testing-library/cypress": "^9.0.0",
14+
"cypress": "^12.0.0",
15+
"typescript": "^4.9.5"
16+
},
17+
"keywords": [
18+
"gatsby"
19+
],
20+
"license": "MIT",
21+
"scripts": {
22+
"develop": "gatsby develop",
23+
"build": "gatsby build",
24+
"clean": "gatsby clean",
25+
"serve": "gatsby serve",
26+
"test": "start-server-and-test develop http://localhost:8000 'cypress run'",
27+
"test:watch": "start-server-and-test develop http://localhost:8000 'cypress open'"
28+
},
29+
"engines": {
30+
"node": ">=18.0.0"
31+
}
32+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React from "react"
2+
3+
export default function Home() {
4+
// Test React 19 features
5+
const [count, setCount] = React.useState(0)
6+
7+
// Test error boundaries
8+
const [error, setError] = React.useState(null)
9+
10+
if (error) {
11+
// Test error boundaries
12+
return <div>Error: {error.message}</div>
13+
}
14+
15+
return (
16+
<div>
17+
<h1>Gatsby + React 19 Test</h1>
18+
<p>Count: {count}</p>
19+
<button onClick={() => setCount(c => c + 1)} data-testid="increment">
20+
Increment
21+
</button>
22+
<button
23+
onClick={() => setError(new Error("Test error"))}
24+
data-testid="error-button"
25+
>
26+
Trigger Error
27+
</button>
28+
</div>
29+
)
30+
}

packages/gatsby-link/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
},
3636
"peerDependencies": {
3737
"@gatsbyjs/reach-router": "^2.0.0",
38-
"react": "^18.0.0 || ^0.0.0",
39-
"react-dom": "^18.0.0 || ^0.0.0"
38+
"react": "^18.0.0 || ^19.0.0 || ^0.0.0",
39+
"react-dom": "^18.0.0 || ^19.0.0 || ^0.0.0"
4040
},
4141
"homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-link#readme",
4242
"keywords": [

packages/gatsby-plugin-cxs/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
"peerDependencies": {
2929
"cxs": ">=5.0.0",
3030
"gatsby": "^5.0.0-next",
31-
"react": "^18.0.0 || ^0.0.0",
32-
"react-dom": "^18.0.0 || ^0.0.0"
31+
"react": "^18.0.0 || ^19.0.0 || ^0.0.0",
32+
"react-dom": "^18.0.0 || ^19.0.0 || ^0.0.0"
3333
},
3434
"repository": {
3535
"type": "git",

packages/gatsby-plugin-feed/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
"main": "index.js",
3333
"peerDependencies": {
3434
"gatsby": "^5.0.0-next",
35-
"react": "^18.0.0 || ^0.0.0",
36-
"react-dom": "^18.0.0 || ^0.0.0"
35+
"react": "^18.0.0 || ^19.0.0 || ^0.0.0",
36+
"react-dom": "^18.0.0 || ^19.0.0 || ^0.0.0"
3737
},
3838
"repository": {
3939
"type": "git",

packages/gatsby-plugin-fullstory/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
},
3535
"peerDependencies": {
3636
"gatsby": "^5.0.0-next",
37-
"react": "^18.0.0 || ^0.0.0",
38-
"react-dom": "^18.0.0 || ^0.0.0"
37+
"react": "^18.0.0 || ^19.0.0 || ^0.0.0",
38+
"react-dom": "^18.0.0 || ^19.0.0 || ^0.0.0"
3939
},
4040
"engines": {
4141
"node": ">=18.0.0"

0 commit comments

Comments
 (0)