Skip to content

Commit 525c1cf

Browse files
committed
Use locally built serverless package instead of pulling from npm in e2e tests
1 parent 5baa31d commit 525c1cf

File tree

1 file changed

+14
-3
lines changed
  • dev-packages/e2e-tests/test-applications/aws-serverless/src

1 file changed

+14
-3
lines changed

dev-packages/e2e-tests/test-applications/aws-serverless/src/stack.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const LAMBDA_FUNCTIONS_WITH_LAYER_DIR = './src/lambda-functions-layer';
1212
const LAMBDA_FUNCTIONS_WITH_NPM_DIR = './src/lambda-functions-npm';
1313
const LAMBDA_FUNCTION_TIMEOUT = 10;
1414
const LAYER_DIR = './node_modules/@sentry/aws-serverless/';
15+
const WORKSPACE_AWS_SERVERLESS_DIR = path.resolve(__dirname, '../../../../../packages/aws-serverless');
1516
const DEFAULT_NODE_VERSION = '22';
1617
export const SAM_PORT = 3001;
1718

@@ -68,9 +69,19 @@ export class LocalLambdaStack extends Stack {
6869

6970
if (!addLayer) {
7071
console.log(`[LocalLambdaStack] Install dependencies for ${functionName}`);
71-
const packageJson = { dependencies: { '@sentry/aws-serverless': '* || latest' } };
72-
fs.writeFileSync(path.join(functionsDir, lambdaDir, 'package.json'), JSON.stringify(packageJson, null, 2));
73-
execFileSync('npm', ['install', '--prefix', path.join(functionsDir, lambdaDir)], { stdio: 'inherit' });
72+
73+
const lambdaPath = path.resolve(functionsDir, lambdaDir);
74+
// Point the dependency at the locally built aws-serverless package so tests use the current workspace bits
75+
const localAwsServerlessPath = path.relative(lambdaPath, WORKSPACE_AWS_SERVERLESS_DIR);
76+
const dependencyPath = localAwsServerlessPath.replace(/\\/g, '/');
77+
const packageJson = {
78+
dependencies: {
79+
'@sentry/aws-serverless': `file:${dependencyPath}`,
80+
},
81+
};
82+
83+
fs.writeFileSync(path.join(lambdaPath, 'package.json'), JSON.stringify(packageJson, null, 2));
84+
execFileSync('npm', ['install', '--prefix', lambdaPath], { stdio: 'inherit' });
7485
}
7586

7687
new CfnResource(this, functionName, {

0 commit comments

Comments
 (0)