Skip to content

Commit 9d7faf8

Browse files
committed
chore: exclude ESM on Node.js 16 from layer tests
1 parent b652643 commit 9d7faf8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

layers/tests/e2e/layerPublisher.test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
TestInvocationLogs,
1212
invokeFunctionOnce,
1313
generateTestUniqueName,
14+
getRuntimeKey,
1415
} from '@aws-lambda-powertools/testing-utils';
1516
import { TestNodejsFunction } from '@aws-lambda-powertools/testing-utils/resources/lambda';
1617
import {
@@ -47,7 +48,13 @@ describe(`Layers E2E tests`, () => {
4748
},
4849
});
4950

50-
const cases = ['CJS', 'ESM'] as const;
51+
/**
52+
* Node.js 16.x does not support importing ESM modules from Lambda Layers reliably.
53+
*
54+
* The feature is available in Node.js 18.x and later.
55+
* @see https://aws.amazon.com/blogs/compute/node-js-18-x-runtime-now-available-in-aws-lambda/
56+
*/
57+
const cases = getRuntimeKey() === 'nodejs16x' ? ['CJS'] : ['CJS', 'ESM'];
5158
const invocationLogsMap: Map<(typeof cases)[number], TestInvocationLogs> =
5259
new Map();
5360

0 commit comments

Comments
 (0)