Skip to content

Commit 4164116

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

File tree

1 file changed

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

1 file changed

+13
-3
lines changed

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,19 @@ export class LocalLambdaStack extends Stack {
6868

6969
if (!addLayer) {
7070
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' });
71+
72+
const lambdaPath = path.resolve(functionsDir, lambdaDir);
73+
// Point the dependency at the locally built aws-serverless package so tests use the current workspace bits
74+
const localAwsServerlessPath = path.relative(lambdaPath, path.resolve(LAYER_DIR));
75+
const dependencyPath = localAwsServerlessPath.replace(/\\/g, '/');
76+
const packageJson = {
77+
dependencies: {
78+
'@sentry/aws-serverless': `file:${dependencyPath}`,
79+
},
80+
};
81+
82+
fs.writeFileSync(path.join(lambdaPath, 'package.json'), JSON.stringify(packageJson, null, 2));
83+
execFileSync('npm', ['install', '--prefix', lambdaPath], { stdio: 'inherit' });
7484
}
7585

7686
new CfnResource(this, functionName, {

0 commit comments

Comments
 (0)