Skip to content

Commit

Permalink
update e2e to run in node 20
Browse files Browse the repository at this point in the history
  • Loading branch information
chargome committed Jan 24, 2025
1 parent aa45243 commit adbaad0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
29 changes: 25 additions & 4 deletions dev-packages/e2e-tests/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,34 @@ import * as dotenv from 'dotenv';
import { sync as globSync } from 'glob';

import { registrySetup } from './registrySetup';
import { readFileSync } from 'fs';

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

function asyncExec(command: string, options: { env: Record<string, string | undefined>; cwd: string }): Promise<void> {
interface PackageJson {
volta?: {
node?: string;
};
}

function getVoltaNodeVersion(packageJsonPath: string): string | undefined {
try {
const packageJson: PackageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
return packageJson.volta?.node;
} catch {
return undefined;
}
}

function asyncExec(
command: string,
options: { env: Record<string, string | undefined>; cwd: string; nodeVersion?: string },
): Promise<void> {
return new Promise((resolve, reject) => {
const process = spawn(command, { ...options, shell: true });
const finalCommand = options.nodeVersion ? `volta run --node ${options.nodeVersion} ${command}` : command;
const process = spawn(finalCommand, { ...options, shell: true });

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

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

console.log(`Building ${testAppPath}...`);
await asyncExec('pnpm test:build', { env, cwd });
await asyncExec('pnpm test:build', { env, cwd, nodeVersion });

console.log(`Testing ${testAppPath}...`);
await asyncExec('pnpm test:assert', { env, cwd });
await asyncExec('pnpm test:assert', { env, cwd, nodeVersion });
}
} catch (error) {
console.error(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,8 @@
"ts-loader": "^9.4.3",
"tsconfig-paths": "^4.2.0",
"typescript": "~5.0.0"
},
"volta": {
"node": "20.18.2"
}
}

0 comments on commit adbaad0

Please sign in to comment.