@@ -87,7 +87,7 @@ describe('<ErrorBoundary />', () => {
8787
8888 describe ( 'when BugSplat has been initialized' , ( ) => {
8989 let bugSplat : BugSplat ;
90- let scope : Pick < Scope , 'getClient' > ;
90+ let scope : Scope ;
9191
9292 beforeEach ( ( ) => {
9393 bugSplat = {
@@ -96,7 +96,7 @@ describe('<ErrorBoundary />', () => {
9696 version : '' ,
9797 post : mockPost ,
9898 } as unknown as BugSplat ;
99- scope = { getClient : ( ) => bugSplat } ;
99+ scope = new Scope ( bugSplat ) ;
100100 } ) ;
101101
102102 it ( 'should call onError' , async ( ) => {
@@ -152,6 +152,41 @@ describe('<ErrorBoundary />', () => {
152152 await waitFor ( ( ) => expect ( mockPost ) . toHaveBeenCalledTimes ( 1 ) ) ;
153153 } ) ;
154154
155+ it ( 'should attach componentStack as a text/plain Blob by default' , async ( ) => {
156+ render (
157+ < ErrorBoundary scope = { scope } fallback = { BasicFallback } >
158+ < BlowUp />
159+ </ ErrorBoundary >
160+ ) ;
161+
162+ await waitFor ( ( ) => expect ( mockPost ) . toHaveBeenCalledTimes ( 1 ) ) ;
163+
164+ const [ , options ] = mockPost . mock . calls [ 0 ] ;
165+ expect ( options . attachments ) . toHaveLength ( 1 ) ;
166+ const [ attachment ] = options . attachments ;
167+ expect ( attachment . filename ) . toBe ( 'componentStack.txt' ) ;
168+ expect ( attachment . data ) . toBeInstanceOf ( Blob ) ;
169+ expect ( attachment . data . type ) . toBe ( 'text/plain' ) ;
170+ } ) ;
171+
172+ it ( 'honors scope.getCreateComponentStackAttachment() when provided' , async ( ) => {
173+ const customAttachment = { filename : 'componentStack.txt' , data : 'CUSTOM' } ;
174+ const customBuilder = jest . fn ( ( ) => customAttachment ) ;
175+ const scopeWithBuilder = new Scope ( bugSplat , customBuilder ) ;
176+
177+ render (
178+ < ErrorBoundary scope = { scopeWithBuilder } fallback = { BasicFallback } >
179+ < BlowUp />
180+ </ ErrorBoundary >
181+ ) ;
182+
183+ await waitFor ( ( ) => expect ( mockPost ) . toHaveBeenCalledTimes ( 1 ) ) ;
184+
185+ expect ( customBuilder ) . toHaveBeenCalledWith ( expect . stringContaining ( 'BlowUp' ) ) ;
186+ const [ , options ] = mockPost . mock . calls [ 0 ] ;
187+ expect ( options . attachments ) . toEqual ( [ customAttachment ] ) ;
188+ } ) ;
189+
155190 it ( 'should call beforePost' , async ( ) => {
156191 render (
157192 < ErrorBoundary
0 commit comments