Skip to content

Commit adbaad0

Browse files
committed
update e2e to run in node 20
1 parent aa45243 commit adbaad0

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

dev-packages/e2e-tests/run.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,34 @@ import * as dotenv from 'dotenv';
55
import { sync as globSync } from 'glob';
66

77
import { registrySetup } from './registrySetup';
8+
import { readFileSync } from 'fs';
89

910
const DEFAULT_DSN = 'https://username@domain/123';
1011
const DEFAULT_SENTRY_ORG_SLUG = 'sentry-javascript-sdks';
1112
const DEFAULT_SENTRY_PROJECT = 'sentry-javascript-e2e-tests';
1213

13-
function asyncExec(command: string, options: { env: Record<string, string | undefined>; cwd: string }): Promise<void> {
14+
interface PackageJson {
15+
volta?: {
16+
node?: string;
17+
};
18+
}
19+
20+
function getVoltaNodeVersion(packageJsonPath: string): string | undefined {
21+
try {
22+
const packageJson: PackageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
23+
return packageJson.volta?.node;
24+
} catch {
25+
return undefined;
26+
}
27+
}
28+
29+
function asyncExec(
30+
command: string,
31+
options: { env: Record<string, string | undefined>; cwd: string; nodeVersion?: string },
32+
): Promise<void> {
1433
return new Promise((resolve, reject) => {
15-
const process = spawn(command, { ...options, shell: true });
34+
const finalCommand = options.nodeVersion ? `volta run --node ${options.nodeVersion} ${command}` : command;
35+
const process = spawn(finalCommand, { ...options, shell: true });
1636

1737
process.stdout.on('data', data => {
1838
console.log(`${data}`);
@@ -75,12 +95,13 @@ async function run(): Promise<void> {
7595

7696
for (const testAppPath of testAppPaths) {
7797
const cwd = resolve('test-applications', testAppPath);
98+
const nodeVersion = getVoltaNodeVersion(resolve(cwd, 'package.json'));
7899

79100
console.log(`Building ${testAppPath}...`);
80-
await asyncExec('pnpm test:build', { env, cwd });
101+
await asyncExec('pnpm test:build', { env, cwd, nodeVersion });
81102

82103
console.log(`Testing ${testAppPath}...`);
83-
await asyncExec('pnpm test:assert', { env, cwd });
104+
await asyncExec('pnpm test:assert', { env, cwd, nodeVersion });
84105
}
85106
} catch (error) {
86107
console.error(error);

dev-packages/e2e-tests/test-applications/nestjs-11/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,8 @@
4444
"ts-loader": "^9.4.3",
4545
"tsconfig-paths": "^4.2.0",
4646
"typescript": "~5.0.0"
47+
},
48+
"volta": {
49+
"node": "20.18.2"
4750
}
4851
}

0 commit comments

Comments
 (0)