@@ -18,14 +18,12 @@ const mockGetSDKSource = vi.mocked(getSDKSource);
1818const mockInitWithoutDefaultIntegrations = vi . mocked ( initWithoutDefaultIntegrations ) ;
1919
2020describe ( 'init' , ( ) => {
21- describe ( 'experimental Lambda extension support ' , ( ) => {
21+ describe ( 'Lambda extension setup ' , ( ) => {
2222 test ( 'should preserve user-provided tunnel option when Lambda extension is enabled' , ( ) => {
2323 mockGetSDKSource . mockReturnValue ( 'aws-lambda-layer' ) ;
2424 const options : AwsServerlessOptions = {
2525 tunnel : 'https://custom-tunnel.example.com' ,
26- _experiments : {
27- enableLambdaExtension : true ,
28- } ,
26+ useLayerExtension : true ,
2927 } ;
3028
3129 init ( options ) ;
@@ -40,9 +38,7 @@ describe('init', () => {
4038 test ( 'should set default tunnel when Lambda extension is enabled and SDK source is aws-lambda-layer' , ( ) => {
4139 mockGetSDKSource . mockReturnValue ( 'aws-lambda-layer' ) ;
4240 const options : AwsServerlessOptions = {
43- _experiments : {
44- enableLambdaExtension : true ,
45- } ,
41+ useLayerExtension : true ,
4642 } ;
4743
4844 init ( options ) ;
@@ -57,9 +53,7 @@ describe('init', () => {
5753 test ( 'should not set tunnel when Lambda extension is disabled' , ( ) => {
5854 mockGetSDKSource . mockReturnValue ( 'aws-lambda-layer' ) ;
5955 const options : AwsServerlessOptions = {
60- _experiments : {
61- enableLambdaExtension : false ,
62- } ,
56+ useLayerExtension : false ,
6357 } ;
6458
6559 init ( options ) ;
@@ -74,9 +68,7 @@ describe('init', () => {
7468 test ( 'should not set tunnel when SDK source is not aws-lambda-layer even with Lambda extension enabled' , ( ) => {
7569 mockGetSDKSource . mockReturnValue ( 'npm' ) ;
7670 const options : AwsServerlessOptions = {
77- _experiments : {
78- enableLambdaExtension : true ,
79- } ,
71+ useLayerExtension : true ,
8072 } ;
8173
8274 init ( options ) ;
@@ -88,17 +80,52 @@ describe('init', () => {
8880 ) ;
8981 } ) ;
9082
91- test ( 'should not set tunnel when no experiments are provided ' , ( ) => {
83+ test ( 'should default useLayerExtension to true when SDK source is aws-lambda-layer ' , ( ) => {
9284 mockGetSDKSource . mockReturnValue ( 'aws-lambda-layer' ) ;
9385 const options : AwsServerlessOptions = { } ;
9486
9587 init ( options ) ;
9688
89+ expect ( mockInitWithoutDefaultIntegrations ) . toHaveBeenCalledWith (
90+ expect . objectContaining ( {
91+ useLayerExtension : true ,
92+ tunnel : 'http://localhost:9000/envelope' ,
93+ } ) ,
94+ ) ;
95+ } ) ;
96+
97+ test ( 'should default useLayerExtension to false when SDK source is not aws-lambda-layer' , ( ) => {
98+ mockGetSDKSource . mockReturnValue ( 'npm' ) ;
99+ const options : AwsServerlessOptions = { } ;
100+
101+ init ( options ) ;
102+
103+ expect ( mockInitWithoutDefaultIntegrations ) . toHaveBeenCalledWith (
104+ expect . objectContaining ( {
105+ useLayerExtension : false ,
106+ } ) ,
107+ ) ;
97108 expect ( mockInitWithoutDefaultIntegrations ) . toHaveBeenCalledWith (
98109 expect . not . objectContaining ( {
99110 tunnel : expect . any ( String ) ,
100111 } ) ,
101112 ) ;
102113 } ) ;
114+
115+ test ( 'should default useLayerExtension to false when tunnel is provided even when SDK source is aws-lambda-layer' , ( ) => {
116+ mockGetSDKSource . mockReturnValue ( 'aws-lambda-layer' ) ;
117+ const options : AwsServerlessOptions = {
118+ tunnel : 'https://custom-tunnel.example.com' ,
119+ } ;
120+
121+ init ( options ) ;
122+
123+ expect ( mockInitWithoutDefaultIntegrations ) . toHaveBeenCalledWith (
124+ expect . objectContaining ( {
125+ useLayerExtension : false ,
126+ tunnel : 'https://custom-tunnel.example.com' ,
127+ } ) ,
128+ ) ;
129+ } ) ;
103130 } ) ;
104131} ) ;
0 commit comments