Skip to content

Commit 1ede3e2

Browse files
Fix serverRenderRSCReactComponent test to pass when run with full test suite
The test was passing when run individually but failing when run with other tests due to shared configuration state. **Root cause:** - The test was directly mutating the global config object instead of calling buildConfig() - It wasn't using a unique serverBundleCachePath like other tests - When other tests ran and called buildConfig() with their own serverBundleCachePath, it would overwrite the path this test expected - This caused the RSC bundle to look for manifest files in the wrong location **Solution:** 1. Use the serverBundleCachePath() helper function to create a unique test-specific directory (following the pattern of other tests) 2. Call buildConfig() in beforeEach to properly set the configuration including the unique serverBundleCachePath 3. This ensures test isolation and prevents config conflicts between different test suites **Result:** ✅ Test passes when run individually ✅ Test passes when run with full test suite (yarn test) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent da797d4 commit 1ede3e2

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

react_on_rails_pro/packages/node-renderer/tests/serverRenderRSCReactComponent.test.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import path from 'path';
22
import fs from 'fs';
33
import { Readable } from 'stream';
44
import { buildExecutionContext, resetVM } from '../src/worker/vm';
5-
import { getConfig } from '../src/shared/configBuilder';
5+
import { buildConfig } from '../src/shared/configBuilder';
6+
import { serverBundleCachePath } from './helper';
67

78
const SimpleWorkingComponent = () => 'hello';
89

@@ -18,13 +19,14 @@ const ComponentWithAsyncError = async () => {
1819
};
1920

2021
describe('serverRenderRSCReactComponent', () => {
22+
const testName = 'serverRenderRSCReactComponent';
2123
let tempDir;
2224
let tempRscBundlePath;
2325
let tempManifestPath;
2426

2527
beforeAll(async () => {
26-
// Create temporary directory
27-
tempDir = path.join(process.cwd(), 'tmp/node-renderer-bundles-test/testing-bundle');
28+
// Create temporary directory using helper to ensure unique path
29+
tempDir = serverBundleCachePath(testName);
2830
fs.mkdirSync(tempDir, { recursive: true });
2931

3032
// Copy rsc-bundle.js to temp directory
@@ -49,10 +51,12 @@ describe('serverRenderRSCReactComponent', () => {
4951
});
5052

5153
beforeEach(async () => {
52-
const config = getConfig();
53-
config.supportModules = true;
54-
config.maxVMPoolSize = 2; // Set a small pool size for testing
55-
config.stubTimers = false;
54+
buildConfig({
55+
serverBundleCachePath: tempDir,
56+
supportModules: true,
57+
stubTimers: false,
58+
maxVMPoolSize: 2,
59+
});
5660
});
5761

5862
afterEach(async () => {

0 commit comments

Comments
 (0)