@@ -102,7 +102,7 @@ describe( 'publishPackages()', () => {
102102 listrTask : { }
103103 } ) ;
104104
105- expect ( vi . mocked ( assertNpmAuthorization ) ) . toHaveBeenCalledExactlyOnceWith ( 'pepe' ) ;
105+ expect ( vi . mocked ( assertNpmAuthorization ) ) . toHaveBeenCalledExactlyOnceWith ( 'pepe' , { useOidc : false } ) ;
106106 } ) ;
107107
108108 it ( 'should throw if npm authorization assertion failed' , async ( ) => {
@@ -115,53 +115,19 @@ describe( 'publishPackages()', () => {
115115 npmOwner : 'fake-pepe'
116116 } ) ) . rejects . toThrow ( 'You must be logged to npm as "pepe" to execute this release step.' ) ;
117117
118- expect ( vi . mocked ( assertNpmAuthorization ) ) . toHaveBeenCalledExactlyOnceWith ( 'fake-pepe' ) ;
118+ expect ( vi . mocked ( assertNpmAuthorization ) ) . toHaveBeenCalledExactlyOnceWith ( 'fake-pepe' , { useOidc : false } ) ;
119119 } ) ;
120120
121- it ( 'should not verify npm authorization when publishing using OIDC (`useOidc=true`) ' , async ( ) => {
122- vi . stubEnv ( 'NPM_ID_TOKEN' , 'oidc-token' ) ;
121+ it ( 'should pass the `useOidc` option to the npm authorization assertion ' , async ( ) => {
122+ vi . mocked ( workspaces . findPathsToPackages ) . mockReset ( ) . mockResolvedValue ( [ ] ) ;
123123
124- const promise = publishPackages ( {
124+ await publishPackages ( {
125125 packagesDirectory : 'packages' ,
126126 useOidc : true ,
127127 listrTask : { }
128128 } ) ;
129129
130- await vi . advanceTimersToNextTimerAsync ( ) ;
131- await promise ;
132-
133- expect ( vi . mocked ( assertNpmAuthorization ) ) . not . toHaveBeenCalled ( ) ;
134- expect ( vi . mocked ( executeInParallel ) ) . toHaveBeenCalledOnce ( ) ;
135- } ) ;
136-
137- it ( 'should throw when publishing using OIDC while the "NPM_ID_TOKEN" environment variable is not set' , async ( ) => {
138- vi . stubEnv ( 'NPM_ID_TOKEN' , undefined ) ;
139-
140- await expect ( publishPackages ( {
141- packagesDirectory : 'packages' ,
142- useOidc : true ,
143- listrTask : { }
144- } ) ) . rejects . toThrow (
145- 'The "NPM_ID_TOKEN" environment variable is required when publishing using npm Trusted Publishing (OIDC).'
146- ) ;
147-
148- expect ( vi . mocked ( assertNpmAuthorization ) ) . not . toHaveBeenCalled ( ) ;
149- expect ( vi . mocked ( executeInParallel ) ) . not . toHaveBeenCalled ( ) ;
150- } ) ;
151-
152- it ( 'should throw when publishing using OIDC while the "NPM_ID_TOKEN" environment variable is empty' , async ( ) => {
153- vi . stubEnv ( 'NPM_ID_TOKEN' , '' ) ;
154-
155- await expect ( publishPackages ( {
156- packagesDirectory : 'packages' ,
157- useOidc : true ,
158- listrTask : { }
159- } ) ) . rejects . toThrow (
160- 'The "NPM_ID_TOKEN" environment variable is required when publishing using npm Trusted Publishing (OIDC).'
161- ) ;
162-
163- expect ( vi . mocked ( assertNpmAuthorization ) ) . not . toHaveBeenCalled ( ) ;
164- expect ( vi . mocked ( executeInParallel ) ) . not . toHaveBeenCalled ( ) ;
130+ expect ( vi . mocked ( assertNpmAuthorization ) ) . toHaveBeenCalledExactlyOnceWith ( undefined , { useOidc : true } ) ;
165131 } ) ;
166132
167133 it ( 'should verify npm authorization when the `useOidc` option is disabled explicitly' , async ( ) => {
@@ -174,7 +140,7 @@ describe( 'publishPackages()', () => {
174140 listrTask : { }
175141 } ) ;
176142
177- expect ( vi . mocked ( assertNpmAuthorization ) ) . toHaveBeenCalledExactlyOnceWith ( 'pepe' ) ;
143+ expect ( vi . mocked ( assertNpmAuthorization ) ) . toHaveBeenCalledExactlyOnceWith ( 'pepe' , { useOidc : false } ) ;
178144 } ) ;
179145
180146 it ( 'should assert that each found directory is a package' , async ( ) => {
0 commit comments