Skip to content

[Feature] Add unit tests for setNewArch command file manipulation logic #2731

@ConnorQi01

Description

@ConnorQi01

Summary

The setNewArch command (src/extension/commands/setNewArch.ts) modifies ios/Podfile and android/gradle.properties to toggle React Native New Architecture. This logic has no unit tests, leaving the file-parsing and write-back paths unverified.

Why this is useful

Similar commands with non-trivial file manipulation — enableHermes, installExpoGoApplication, prebuild, configEASBuild — all have unit tests. Adding tests for setNewArch closes a consistency gap and guards against regressions when the New Architecture flags or file formats change.

Suggested scope

  • Add test/extension/commands/setNewArch.test.ts following the proxyquire/sinon pattern used by adjacent tests
  • Cover: Android path (gradle.properties has existing newArchEnabled entry vs. missing entry), iOS path (Podfile includes the disable line vs. does not), and user-cancellation (QuickPick returns undefined)
  • Fix the typo in InternalErrorCode: FaiedToSetNewArchFailedToSetNewArch (src/common/error/internalErrorCode.ts:40)

Evidence

  • src/extension/commands/setNewArch.ts — 87 lines, no corresponding test file under test/extension/commands/
  • src/common/error/internalErrorCode.ts:40FaiedToSetNewArch = 135 (typo)
  • Comparable test: test/extension/commands/enableHermes.test.ts uses temp-dir + proxyquire pattern that applies directly here

Validation

  • npm test passes with the new test file included
  • Both Android and iOS branches exercised in isolation without touching real project files

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions