@@ -50,6 +50,38 @@ describe("uploadScreenshots", () => {
5050 } ) ;
5151 } ) ;
5252
53+ it ( "handles invalid xcresultPath gracefully" , async ( ) => {
54+ mockedGetApps . mockReturnValue ( [ mockApp ] ) ;
55+ mockedGetApp . mockReturnValue ( mockApp ) ;
56+ process . env . FIREBASE_SERVICE_ACCOUNT = JSON . stringify ( {
57+ type : "service_account" ,
58+ } ) ;
59+ process . env . FIREBASE_STORAGE_BUCKET = "bucket-name" ;
60+
61+ const invalidXcresultPath = "./nonexistent/path" ;
62+ await expect (
63+ uploadScreenshots ( 123 , invalidXcresultPath , "./src/tests/exampleFiles" )
64+ ) . rejects . toThrow ( "The specified xcresultPath does not exist." ) ;
65+
66+ // Additional assertions can be added here
67+ } ) ;
68+
69+ it ( "throws an error if the Firebase service account is corrupted" , async ( ) => {
70+ // Set environment variables to undefined to simulate the missing service account
71+ process . env . FIREBASE_SERVICE_ACCOUNT = undefined ;
72+ mockedGetApps . mockReturnValue ( [ ] ) ;
73+ await expect (
74+ uploadScreenshots ( 123 , "/path/to/xcresult" , "/path/to/screenshots" )
75+ ) . rejects . toThrow (
76+ "In order to upload, you have to set FIREBASE_STORAGE_BUCKET and FIREBASE_SERVICE_ACCOUNT in the environment variables."
77+ ) ;
78+
79+ // Reset the environment variables after the test
80+ process . env . FIREBASE_SERVICE_ACCOUNT = JSON . stringify ( {
81+ type : "service_account" ,
82+ } ) ;
83+ } ) ;
84+
5385 it ( "successfully uploads screenshots and returns download URLs" , async ( ) => {
5486 mockedGetApps . mockReturnValue ( [ mockApp ] ) ;
5587 mockedGetApp . mockReturnValue ( mockApp ) ;
0 commit comments