Skip to content

Commit 21d0c0b

Browse files
Update dependencies and improve Jest configuration for react-on-rails-pro
- Changed the version of "react-on-rails" in package.json from "^16.1.0" to "16.1.0" for consistency. - Enhanced jest.config.js to allow Jest to transform the react-on-rails package from node_modules. - Updated import paths in test files to reflect the new structure, ensuring proper module resolution. - Added TypeScript error suppression for async components in SuspenseHydration.test.tsx. These changes enhance the testing setup and ensure compatibility with the updated package structure.
1 parent 8caa9a1 commit 21d0c0b

File tree

6 files changed

+89
-124
lines changed

6 files changed

+89
-124
lines changed

packages/react-on-rails-pro/jest.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ export default {
2626
}
2727
: {},
2828

29+
// Allow Jest to transform react-on-rails package from node_modules
30+
transformIgnorePatterns: ['node_modules/(?!react-on-rails)'],
31+
2932
// Set root directory to current package
3033
rootDir: '.',
3134
};

packages/react-on-rails-pro/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"./ServerComponentFetchError": "./lib/ServerComponentFetchError.js"
4545
},
4646
"dependencies": {
47-
"react-on-rails": "^16.1.0"
47+
"react-on-rails": "16.1.0"
4848
},
4949
"peerDependencies": {
5050
"react": ">= 16",

packages/react-on-rails-pro/tests/SuspenseHydration.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const AsyncComponentContainer = ({
5050
});
5151
return (
5252
<Suspense fallback={<div>Loading...</div>}>
53+
{/* @ts-expect-error - AsyncComponent is a valid React 19 async component, but TypeScript doesn't recognize it yet */}
5354
<AsyncComponent promise={promise} onRendered={onAsyncComponentRendered} />
5455
</Suspense>
5556
);

packages/react-on-rails-pro/tests/injectRSCPayload.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Readable, PassThrough } from 'stream';
2-
import { RailsContextWithServerStreamingCapabilities } from '../src/types/index.ts';
3-
import injectRSCPayload from '../src/pro/injectRSCPayload.ts';
4-
import RSCRequestTracker from '../src/pro/RSCRequestTracker.ts';
2+
import { RailsContextWithServerStreamingCapabilities } from 'react-on-rails/types';
3+
import injectRSCPayload from '../src/injectRSCPayload.ts';
4+
import RSCRequestTracker from '../src/RSCRequestTracker.ts';
55

66
// Shared utilities
77
const createMockStream = (chunks: (string | Buffer)[] | { [key: number]: string | string[] }) => {

packages/react-on-rails-pro/tests/registerServerComponent.client.test.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { screen, act } from '@testing-library/react';
99
import '@testing-library/jest-dom';
1010
import * as path from 'path';
1111
import * as fs from 'fs';
12-
import { createNodeReadableStream, getNodeVersion } from '../../react-on-rails/tests/testUtils.js';
12+
import { createNodeReadableStream, getNodeVersion } from './testUtils.js';
1313
import ReactOnRails from '../src/index.ts';
1414
import registerServerComponent from '../src/registerServerComponent/client.tsx';
1515
import { clear as clearComponentRegistry } from '../src/ComponentRegistry.ts';
@@ -44,7 +44,7 @@ enableFetchMocks();
4444

4545
expect(() => {
4646
// Re-import to trigger the check
47-
jest.requireActual('../src/pro/wrapServerComponentRenderer/client.tsx');
47+
jest.requireActual('../src/wrapServerComponentRenderer/client.tsx');
4848
}).toThrow('React.use is not defined');
4949
});
5050

0 commit comments

Comments
 (0)