@@ -68,13 +68,15 @@ describe("runtime-setup", () => {
6868 ) ;
6969 } ) ;
7070
71- it ( "should throw if LAMBDA_TASK_ROOT is not set" , async ( ) => {
71+ it ( "should fall back to process.cmd() when LAMBDA_TASK_ROOT is not set" , async ( ) => {
7272 // GIVEN
7373 delete process . env . LAMBDA_TASK_ROOT ;
7474
7575 // WHEN & THEN
76- await expect ( createRuntime ( ) ) . rejects . toThrow (
77- "LAMBDA_TASK_ROOT environment variable is not set" ,
76+ await createRuntime ( ) ;
77+ expect ( UserFunctionLoader . load ) . toHaveBeenCalledWith (
78+ process . cwd ( ) ,
79+ expect . any ( String ) ,
7880 ) ;
7981 } ) ;
8082 } ) ;
@@ -150,7 +152,7 @@ describe("runtime-setup", () => {
150152 // GIVEN
151153 process . env . AWS_LAMBDA_RUNTIME_API = "test-api:8080" ;
152154 process . env . _HANDLER = "index.handler" ;
153- process . env . LAMBDA_TASK_ROOT = "/test/path " ;
155+ process . env . LAMBDA_TASK_ROOT = "/var/task " ;
154156
155157 // WHEN
156158 await createRuntime ( ) ;
@@ -167,7 +169,7 @@ describe("runtime-setup", () => {
167169 // GIVEN
168170 process . env . AWS_LAMBDA_RUNTIME_API = "test-api:8080" ;
169171 process . env . _HANDLER = "index.handler" ;
170- process . env . LAMBDA_TASK_ROOT = "/test/path " ;
172+ process . env . LAMBDA_TASK_ROOT = "/var/task " ;
171173 process . env . AWS_LAMBDA_LOG_FORMAT = "JSON" ;
172174
173175 // WHEN
@@ -184,7 +186,7 @@ describe("runtime-setup", () => {
184186 // GIVEN
185187 process . env . AWS_LAMBDA_RUNTIME_API = "test-api:8080" ;
186188 process . env . _HANDLER = "index.handler" ;
187- process . env . LAMBDA_TASK_ROOT = "/test/path " ;
189+ process . env . LAMBDA_TASK_ROOT = "/var/task " ;
188190 process . env . AWS_LAMBDA_LOG_LEVEL = "ERROR" ;
189191
190192 // WHEN
0 commit comments