@@ -80,21 +80,26 @@ describe('publish-npm', () => {
8080 jest . resetAllMocks ( ) ;
8181 } ) ;
8282
83- describe ( 'publish-npm.js' , ( ) => {
84- it ( 'should fail when invalid build type is passed' , async ( ) => {
85- // Call actual function
86- // $FlowExpectedError[underconstrained-implicit-instantiation]
87- const npmUtils = jest . requireActual ( '../../releases/utils/npm-utils' ) ;
88- getNpmInfoMock . mockImplementation ( npmUtils . getNpmInfo ) ;
83+ it ( 'should fail when invalid build type is passed' , async ( ) => {
84+ // Call actual function
85+ // $FlowExpectedError[underconstrained-implicit-instantiation]
86+ const npmUtils = jest . requireActual ( '../../releases/utils/npm-utils' ) ;
87+ getNpmInfoMock . mockImplementation ( npmUtils . getNpmInfo ) ;
88+
89+ await expect ( async ( ) => {
90+ // $FlowExpectedError[incompatible-type]
91+ await publishNpm ( 'invalid' ) ;
92+ } ) . rejects . toThrow ( 'Unsupported build type: invalid' ) ;
93+ } ) ;
8994
90- await expect ( async ( ) => {
91- // $FlowExpectedError[incompatible-type]
92- await publishNpm ( 'invalid' ) ;
93- } ) . rejects . toThrow ( 'Unsupported build type: invalid' ) ;
95+ describe ( 'dry-run' , ( ) => {
96+ beforeEach ( ( ) => {
97+ jest . mock ( '../../shared/monorepoUtils' , ( ) => ( {
98+ ...jest . requireActual ( '../../shared/monorepoUtils' ) ,
99+ getWorkspaceRoot : jest . fn ( ) . mockResolvedValue ( { version : '1000.0.0' } ) ,
100+ } ) ) ;
94101 } ) ;
95- } ) ;
96102
97- describe ( "publishNpm('dry-run')" , ( ) => {
98103 it ( 'should set version, hermes version, and not publish' , async ( ) => {
99104 const version = '1000.0.0-currentco' ;
100105 getNpmInfoMock . mockReturnValueOnce ( {
@@ -122,35 +127,73 @@ describe('publish-npm', () => {
122127 expect ( publishPackageMock ) . not . toHaveBeenCalled ( ) ;
123128 } ) ;
124129
125- it ( 'should set version, not set hermes version, and not publish' , async ( ) => {
126- const version = '1000.0.0-currentco' ;
127- getNpmInfoMock . mockReturnValueOnce ( {
128- version,
129- tag : null ,
130+ describe ( 'when on stable branch' , ( ) => {
131+ it ( 'main → RC0: should skip Hermes version' , async ( ) => {
132+ const version = '1000.0.0-currentco' ;
133+ getNpmInfoMock . mockReturnValueOnce ( {
134+ version,
135+ tag : null ,
136+ } ) ;
137+ getBranchName . mockReturnValueOnce ( '0.83-stable' ) ;
138+
139+ await publishNpm ( 'dry-run' ) ;
140+
141+ expect ( updateHermesVersionsToNightlyMock ) . not . toHaveBeenCalled ( ) ;
142+ expect ( setVersionMock ) . not . toBeCalled ( ) ;
143+ expect ( updateReactNativeArtifactsMock ) . toBeCalledWith (
144+ version ,
145+ 'dry-run' ,
146+ ) ;
147+
148+ // Generate Android artifacts is now delegate to build_android entirely
149+ expect ( generateAndroidArtifactsMock ) . not . toHaveBeenCalled ( ) ;
150+
151+ expect ( consoleLogMock ) . toHaveBeenCalledWith (
152+ 'Skipping `npm publish` because --dry-run is set.' ,
153+ ) ;
154+
155+ // Expect termination
156+ expect ( publishAndroidArtifactsToMavenMock ) . not . toHaveBeenCalled ( ) ;
157+ expect ( publishExternalArtifactsToMavenMock ) . not . toHaveBeenCalled ( ) ;
158+ expect ( publishPackageMock ) . not . toHaveBeenCalled ( ) ;
130159 } ) ;
131- getBranchName . mockReturnValueOnce ( '0.83-stable' ) ;
132160
133- await publishNpm ( 'dry-run' ) ;
134-
135- expect ( updateHermesVersionsToNightlyMock ) . not . toHaveBeenCalled ( ) ;
136- expect ( setVersionMock ) . not . toBeCalled ( ) ;
137- expect ( updateReactNativeArtifactsMock ) . toBeCalledWith ( version , 'dry-run' ) ;
138-
139- // Generate Android artifacts is now delegate to build_android entirely
140- expect ( generateAndroidArtifactsMock ) . not . toHaveBeenCalled ( ) ;
141-
142- expect ( consoleLogMock ) . toHaveBeenCalledWith (
143- 'Skipping `npm publish` because --dry-run is set.' ,
144- ) ;
145-
146- // Expect termination
147- expect ( publishAndroidArtifactsToMavenMock ) . not . toHaveBeenCalled ( ) ;
148- expect ( publishExternalArtifactsToMavenMock ) . not . toHaveBeenCalled ( ) ;
149- expect ( publishPackageMock ) . not . toHaveBeenCalled ( ) ;
161+ it ( 'RC0 → RC1: should skip Hermes version and artifacts' , async ( ) => {
162+ const version = '0.83.0-rc.0' ;
163+ getNpmInfoMock . mockReturnValueOnce ( {
164+ version,
165+ tag : null ,
166+ } ) ;
167+ getBranchName . mockReturnValueOnce ( '0.83-stable' ) ;
168+ jest . mock ( '../../shared/monorepoUtils' , ( ) => ( {
169+ ...jest . requireActual ( '../../shared/monorepoUtils' ) ,
170+ getWorkspaceRoot : jest
171+ . fn ( )
172+ . mockResolvedValue ( { version : '0.83.0-rc.0' } ) ,
173+ } ) ) ;
174+
175+ await publishNpm ( 'dry-run' ) ;
176+
177+ expect ( updateHermesVersionsToNightlyMock ) . not . toHaveBeenCalled ( ) ;
178+ expect ( setVersionMock ) . not . toBeCalled ( ) ;
179+ expect ( updateReactNativeArtifactsMock ) . not . toBeCalled ( ) ;
180+
181+ // Generate Android artifacts is now delegate to build_android entirely
182+ expect ( generateAndroidArtifactsMock ) . not . toHaveBeenCalled ( ) ;
183+
184+ expect ( consoleLogMock ) . toHaveBeenCalledWith (
185+ 'Skipping `npm publish` because --dry-run is set.' ,
186+ ) ;
187+
188+ // Expect termination
189+ expect ( publishAndroidArtifactsToMavenMock ) . not . toHaveBeenCalled ( ) ;
190+ expect ( publishExternalArtifactsToMavenMock ) . not . toHaveBeenCalled ( ) ;
191+ expect ( publishPackageMock ) . not . toHaveBeenCalled ( ) ;
192+ } ) ;
150193 } ) ;
151194 } ) ;
152195
153- describe ( "publishNpm( 'nightly')" , ( ) => {
196+ describe ( 'nightly' , ( ) => {
154197 beforeAll ( ( ) => {
155198 jest . mock ( '../../shared/monorepoUtils' , ( ) => ( {
156199 ...jest . requireActual ( '../../shared/monorepoUtils' ) ,
@@ -308,7 +351,7 @@ describe('publish-npm', () => {
308351 } ) ;
309352 } ) ;
310353
311- describe ( "publishNpm( 'release')" , ( ) => {
354+ describe ( 'release' , ( ) => {
312355 it ( 'should publish non-latest' , async ( ) => {
313356 const expectedVersion = '0.81.1' ;
314357 getNpmInfoMock . mockImplementation ( ( ) => ( {
0 commit comments