Skip to content

Commit 7a5d4de

Browse files
authored
Mute console.log in remove-spm-injection-test.js
## Summary: The JavaScript test job in CI prints hundreds of `[generate-spm-xcodeproj]` log lines. All of them come from one test file, `remove-spm-injection-test.js`. Its tests set up the SwiftPM injection in a new temporary app many times. Each setup prints up to 5 lines: 3 for stub `Package.swift` files, 1 for the project file, and 1 for the scheme. The file did not mute `console.log`, so it printed 584 lines in one run. This change mutes `console.log` for every test in that file, and restores it after each test. `generate-spm-xcodeproj-test.js` already does the same thing. Only the test changes. The SwiftPM scripts log the same as before. ## Changelog: [INTERNAL] [CHANGED] - Mute console.log in remove-spm-injection-test.js ## Test Plan: ``` yarn jest --no-cache -i packages/react-native/scripts/spm/__tests__/remove-spm-injection-test.js ``` | | Before | After | |---|---|---| | Tests | 100 passed | 100 passed | | `[generate-spm-xcodeproj]` lines in the output | 584 | 0 | The one test that checks log output (`Kept ReactNativeSPM/…`) uses its own spy and still passes. Differential Revision: D132257870 Pull Request resolved: #60022
1 parent c8b6201 commit 7a5d4de

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎packages/react-native/scripts/spm/__tests__/remove-spm-injection-test.js‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,14 @@ const PLAIN = fs.readFileSync(
2929
);
3030

3131
let scaffoldedAppRoots = [];
32+
let logSpy;
33+
34+
beforeEach(() => {
35+
logSpy = jest.spyOn(console, 'log').mockImplementation(() => {});
36+
});
3237

3338
afterEach(() => {
39+
logSpy.mockRestore();
3440
for (const appRoot of scaffoldedAppRoots) {
3541
fs.rmSync(appRoot, {recursive: true, force: true});
3642
}
@@ -706,12 +712,11 @@ describe('removeSpmInjection — the surgical inverse of add', () => {
706712
xcodeprojPath,
707713
});
708714
rebaseDebugOnUserXcconfig(xcodeprojPath);
709-
const logSpy = jest.spyOn(console, 'log').mockImplementation(() => {});
715+
logSpy.mockClear();
710716

711717
removeSpmInjection({appRoot, xcodeprojPath});
712718

713719
const logged = logSpy.mock.calls.map(([line]) => line).join('\n');
714-
logSpy.mockRestore();
715720
expect(pbxprojOf(xcodeprojPath)).toContain(
716721
'baseConfigurationReference = CC0000000000000000000001 /* App.xcconfig */;',
717722
);

0 commit comments

Comments
 (0)