@@ -122,48 +122,48 @@ describe('_mockNpmShow', () => {
122122
123123 it ( "errors if package doesn't exist" , ( ) => {
124124 const emptyData = _makeRegistryData ( { } ) ;
125- const result = _mockNpmShow ( emptyData , [ 'foo' ] , { } ) ;
125+ const result = _mockNpmShow ( emptyData , [ 'foo' ] , { cwd : undefined } ) ;
126126 expect ( result ) . toEqual ( getShowResult ( { error : '[fake] code E404 - foo - not found' } ) ) ;
127127 } ) ;
128128
129129 it ( 'returns requested version plus dist-tags and version list' , ( ) => {
130- const result = _mockNpmShow ( data , [ 'foo@1.0.0' ] , { } ) ;
130+ const result = _mockNpmShow ( data , [ 'foo@1.0.0' ] , { cwd : undefined } ) ;
131131 expect ( result ) . toEqual ( getShowResult ( { data : data , name : 'foo' , version : '1.0.0' } ) ) ;
132132 } ) ;
133133
134134 it ( 'returns requested version of scoped package' , ( ) => {
135- const result = _mockNpmShow ( data , [ '@foo/bar@2.0.0' ] , { } ) ;
135+ const result = _mockNpmShow ( data , [ '@foo/bar@2.0.0' ] , { cwd : undefined } ) ;
136136 expect ( result ) . toEqual ( getShowResult ( { data, name : '@foo/bar' , version : '2.0.0' } ) ) ;
137137 } ) ;
138138
139139 it ( 'returns requested tag' , ( ) => {
140- const result = _mockNpmShow ( data , [ 'foo@beta' ] , { } ) ;
140+ const result = _mockNpmShow ( data , [ 'foo@beta' ] , { cwd : undefined } ) ;
141141 expect ( result ) . toEqual ( getShowResult ( { data, name : 'foo' , version : '1.0.0-beta' } ) ) ;
142142 } ) ;
143143
144144 it ( 'returns requested tag of scoped package' , ( ) => {
145- const result = _mockNpmShow ( data , [ '@foo/bar@beta' ] , { } ) ;
145+ const result = _mockNpmShow ( data , [ '@foo/bar@beta' ] , { cwd : undefined } ) ;
146146 expect ( result ) . toEqual ( getShowResult ( { data, name : '@foo/bar' , version : '2.0.0-beta' } ) ) ;
147147 } ) ;
148148
149149 it ( 'returns latest version if no version requested' , ( ) => {
150- const result = _mockNpmShow ( data , [ 'foo' ] , { } ) ;
150+ const result = _mockNpmShow ( data , [ 'foo' ] , { cwd : undefined } ) ;
151151 expect ( result ) . toEqual ( getShowResult ( { data, name : 'foo' , version : '1.0.1' } ) ) ;
152152 } ) ;
153153
154154 it ( 'returns latest version of scoped package if no version requested' , ( ) => {
155- const result = _mockNpmShow ( data , [ '@foo/bar' ] , { } ) ;
155+ const result = _mockNpmShow ( data , [ '@foo/bar' ] , { cwd : undefined } ) ;
156156 expect ( result ) . toEqual ( getShowResult ( { data, name : '@foo/bar' , version : '2.0.1' } ) ) ;
157157 } ) ;
158158
159159 it ( "errors if requested version doesn't exist" , ( ) => {
160- const result = _mockNpmShow ( data , [ 'foo@2.0.0' ] , { } ) ;
160+ const result = _mockNpmShow ( data , [ 'foo@2.0.0' ] , { cwd : undefined } ) ;
161161 expect ( result ) . toEqual ( getShowResult ( { error : '[fake] code E404 - foo@2.0.0 - not found' } ) ) ;
162162 } ) ;
163163
164164 // support for this could be added later
165165 it ( 'currently throws if requested version is a range' , ( ) => {
166- expect ( ( ) => _mockNpmShow ( data , [ 'foo@^1.0.0' ] , { } ) ) . toThrow ( / n o t c u r r e n t l y s u p p o r t e d / ) ;
166+ expect ( ( ) => _mockNpmShow ( data , [ 'foo@^1.0.0' ] , { cwd : undefined } ) ) . toThrow ( / n o t c u r r e n t l y s u p p o r t e d / ) ;
167167 } ) ;
168168} ) ;
169169
@@ -199,7 +199,7 @@ describe('_mockNpmPublish', () => {
199199 } ) ;
200200
201201 it ( 'throws if cwd is not specified' , ( ) => {
202- expect ( ( ) => _mockNpmPublish ( { } , [ ] , { } ) ) . toThrow ( 'cwd is required for mock npm publish' ) ;
202+ expect ( ( ) => _mockNpmPublish ( { } , [ ] , { cwd : undefined } ) ) . toThrow ( 'cwd is required for mock npm publish' ) ;
203203 } ) ;
204204
205205 it ( 'errors if reading package.json fails' , ( ) => {
@@ -294,7 +294,7 @@ describe('mockNpm', () => {
294294
295295 it ( 'mocks npm show' , async ( ) => {
296296 npmMock . setRegistryData ( { foo : { versions : [ '1.0.0' ] } } ) ;
297- const result = await npm ( [ 'show' , 'foo' ] ) ;
297+ const result = await npm ( [ 'show' , 'foo' ] , { cwd : undefined } ) ;
298298 expect ( result ) . toMatchObject ( {
299299 success : true ,
300300 stdout : expect . stringContaining ( '"name":"foo"' ) ,
@@ -304,7 +304,7 @@ describe('mockNpm', () => {
304304 it ( 'resets calls and registry after each test' , async ( ) => {
305305 expect ( npmMock . mock ) . not . toHaveBeenCalled ( ) ;
306306 // registry data for foo was set in the previous test but should have been cleared
307- const result = await npm ( [ 'show' , 'foo' ] ) ;
307+ const result = await npm ( [ 'show' , 'foo' ] , { cwd : undefined } ) ;
308308 expect ( result ) . toMatchObject ( {
309309 success : false ,
310310 stderr : expect . stringContaining ( 'not found' ) ,
@@ -313,7 +313,7 @@ describe('mockNpm', () => {
313313
314314 it ( 'can "publish" a package to registry with helper' , async ( ) => {
315315 npmMock . publishPackage ( { name : 'foo' , version : '1.0.0' } ) ;
316- const result = await npm ( [ 'show' , 'foo' ] ) ;
316+ const result = await npm ( [ 'show' , 'foo' ] , { cwd : undefined } ) ;
317317 expect ( result ) . toMatchObject ( {
318318 success : true ,
319319 stdout : expect . stringContaining ( '"name":"foo"' ) ,
@@ -330,22 +330,22 @@ describe('mockNpm', () => {
330330 } ) ;
331331
332332 it ( 'throws on unsupported command' , async ( ) => {
333- await expect ( ( ) => npm ( [ 'pack' ] ) ) . rejects . toThrow ( 'Command not supported by mock npm: pack' ) ;
333+ await expect ( ( ) => npm ( [ 'pack' ] , { cwd : undefined } ) ) . rejects . toThrow ( 'Command not supported by mock npm: pack' ) ;
334334 } ) ;
335335
336336 it ( 'respects mocked command' , async ( ) => {
337337 const mockShow = jest . fn ( ( ) => 'hi' ) ;
338338 npmMock . setCommandOverride ( 'show' , mockShow as any ) ;
339- const result = await npm ( [ 'show' , 'foo' ] ) ;
339+ const result = await npm ( [ 'show' , 'foo' ] , { cwd : undefined } ) ;
340340 expect ( result ) . toEqual ( 'hi' ) ;
341- expect ( mockShow ) . toHaveBeenCalledWith ( expect . any ( Object ) , [ 'foo' ] , undefined ) ;
341+ expect ( mockShow ) . toHaveBeenCalledWith ( expect . any ( Object ) , [ 'foo' ] , { cwd : undefined } ) ;
342342 } ) ;
343343
344344 it ( "respects extra mocked command that's not normally supported" , async ( ) => {
345345 const mockPack = jest . fn ( ( ) => 'hi' ) ;
346346 npmMock . setCommandOverride ( 'pack' , mockPack as any ) ;
347- const result = await npm ( [ 'pack' ] ) ;
347+ const result = await npm ( [ 'pack' ] , { cwd : undefined } ) ;
348348 expect ( result ) . toEqual ( 'hi' ) ;
349- expect ( mockPack ) . toHaveBeenCalledWith ( expect . any ( Object ) , [ ] , undefined ) ;
349+ expect ( mockPack ) . toHaveBeenCalledWith ( expect . any ( Object ) , [ ] , { cwd : undefined } ) ;
350350 } ) ;
351351} ) ;
0 commit comments