@@ -67,21 +67,22 @@ describe('BugsnagSourceMapUploaderPlugin', () => {
6767
6868 const sourcemapUpload = vi . mocked ( Bugsnag . Upload . Js )
6969 const outputDir = resolve ( fixturesPath , 'dist' )
70- const bundlePath = resolve ( outputDir , 'assets/index-DTHX3LI9.js' )
71- const sourceMapPath = resolve ( outputDir , 'assets/index-DTHX3LI9.js.map' )
7270
7371 expect ( mockLogger . info ) . toHaveBeenCalledWith ( '[BugsnagSourceMapUploaderPlugin] uploading sourcemaps using the bugsnag-cli' )
7472 expect ( mockLogger . info ) . toHaveBeenCalledWith ( '[BugsnagSourceMapUploaderPlugin] Sourcemaps uploaded successfully' )
75- expect ( sourcemapUpload ) . toHaveBeenCalledExactlyOnceWith ( {
76- apiKey : 'test-api' ,
77- bundleUrl : 'https://bugsnag.com/assets/index-DTHX3LI9.js' ,
78- bundle : bundlePath ,
79- projectRoot : fixturesPath ,
80- sourceMap : sourceMapPath ,
81- versionName : '1.0.0'
82- } ,
83- outputDir
84- )
73+ expect ( sourcemapUpload ) . toHaveBeenCalledOnce ( )
74+
75+ const [ uploadOptions , targetDir ] = sourcemapUpload . mock . calls [ 0 ]
76+ expect ( uploadOptions ) . toBeDefined ( )
77+ expect ( uploadOptions ) . toMatchObject ( {
78+ apiKey : 'test-api' ,
79+ projectRoot : fixturesPath ,
80+ versionName : '1.0.0'
81+ } )
82+ expect ( uploadOptions ! . bundleUrl ) . toMatch ( / ^ h t t p s : \/ \/ b u g s n a g \. c o m \/ a s s e t s \/ i n d e x - [ a - z A - Z 0 - 9 ] + \. j s $ / )
83+ expect ( uploadOptions ! . bundle ) . toMatch ( / \/ a s s e t s \/ i n d e x - [ a - z A - Z 0 - 9 ] + \. j s $ / )
84+ expect ( uploadOptions ! . sourceMap ) . toMatch ( / \/ a s s e t s \/ i n d e x - [ a - z A - Z 0 - 9 ] + \. j s \. m a p $ / )
85+ expect ( targetDir ) . toBe ( outputDir )
8586 } )
8687
8788 test ( 'should use the relative filepath for bundleUrl if base is not provided in config' , async ( ) => {
@@ -110,21 +111,22 @@ describe('BugsnagSourceMapUploaderPlugin', () => {
110111
111112 const sourcemapUpload = vi . mocked ( Bugsnag . Upload . Js )
112113 const outputDir = resolve ( fixturePath , 'dist' )
113- const bundlePath = resolve ( outputDir , 'assets/index-DTHX3LI9.js' )
114- const sourceMapPath = resolve ( outputDir , 'assets/index-DTHX3LI9.js.map' )
115114
116115 expect ( mockLogger . info ) . toHaveBeenCalledWith ( '[BugsnagSourceMapUploaderPlugin] uploading sourcemaps using the bugsnag-cli' )
117116 expect ( mockLogger . info ) . toHaveBeenCalledWith ( '[BugsnagSourceMapUploaderPlugin] Sourcemaps uploaded successfully' )
118- expect ( sourcemapUpload ) . toHaveBeenCalledExactlyOnceWith ( {
119- apiKey : 'test-api' ,
120- bundleUrl : '/assets/index-DTHX3LI9.js' ,
121- bundle : bundlePath ,
122- projectRoot : fixturePath ,
123- sourceMap : sourceMapPath ,
124- versionName : version
125- } ,
126- outputDir
127- )
117+ expect ( sourcemapUpload ) . toHaveBeenCalledOnce ( )
118+
119+ const [ uploadOptions , targetDir ] = sourcemapUpload . mock . calls [ 0 ]
120+ expect ( uploadOptions ) . toBeDefined ( )
121+ expect ( uploadOptions ) . toMatchObject ( {
122+ apiKey : 'test-api' ,
123+ projectRoot : fixturePath ,
124+ versionName : version
125+ } )
126+ expect ( uploadOptions ! . bundleUrl ) . toMatch ( / ^ \/ a s s e t s \/ i n d e x - [ a - z A - Z 0 - 9 ] + \. j s $ / )
127+ expect ( uploadOptions ! . bundle ) . toMatch ( / \/ a s s e t s \/ i n d e x - [ a - z A - Z 0 - 9 ] + \. j s $ / )
128+ expect ( uploadOptions ! . sourceMap ) . toMatch ( / \/ a s s e t s \/ i n d e x - [ a - z A - Z 0 - 9 ] + \. j s \. m a p $ / )
129+ expect ( targetDir ) . toBe ( outputDir )
128130 } )
129131
130132 test ( 'logs an error if the upload fails' , async ( ) => {
0 commit comments