Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(e2e): Enable ESM loader test #11912

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ jobs:
'create-remix-app-express',
'create-remix-app-express-vite-dev',
'debug-id-sourcemaps',
# 'esm-loader-node-express-app', # This is currently broken for upstream reasons. See https://github.com/getsentry/sentry-javascript/pull/11338#issuecomment-2025450675
'esm-loader-node-express-app',
'nextjs-app-dir',
'nextjs-14',
'react-create-hash-router',
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"yaml": "2.2.2"
},
"volta": {
"node": "18.18.0",
"node": "18.19.1",
"yarn": "1.22.19",
"pnpm": "8.15.5"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,19 @@
"version": "1.0.0",
"private": true,
"scripts": {
"start": "node --import=@sentry/node/import-hook src/app.mjs",
"start": "node --import ./src/instrument.mjs src/app.mjs",
"clean": "npx rimraf node_modules,pnpm-lock.yaml",
"test:build": "pnpm install",
"test:assert": "playwright test"
},
"dependencies": {
"@sentry/node": "latest || *",
"@sentry/types": "latest || *",
"express": "4.19.2",
"@types/express": "4.17.17",
"@types/node": "18.15.1",
"typescript": "4.9.5"
"@sentry/opentelemetry": "latest || *",
"express": "4.19.2"
},
"devDependencies": {
"@sentry-internal/event-proxy-server": "link:../../../event-proxy-server",
"@playwright/test": "^1.27.1",
"ts-node": "10.9.1"
"@playwright/test": "^1.27.1"
},
"volta": {
"extends": "../../package.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ const config: PlaywrightTestConfig = {
/* Run your local dev server before starting the tests */
webServer: [
{
command: 'pnpm ts-node-script start-event-proxy.ts',
command: 'pnpm ts-node-script start-event-proxy.mjs',
port: eventProxyPort,
stdout: 'pipe',
stderr: 'pipe',
},
{
command: 'pnpm start',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import * as Sentry from '@sentry/node';

Sentry.init({
environment: 'qa', // dynamic sampling bias to keep transactions
dsn: process.env.E2E_TEST_DSN,
debug: true,
tunnel: `http://localhost:3031/`, // proxy server
tracesSampleRate: 1,
});
// @ts-check

import * as Sentry from '@sentry/node';
import express from 'express';

const app = express();
Expand Down Expand Up @@ -36,7 +29,6 @@ app.get('/test-error', function (req, res) {

Sentry.setupExpressErrorHandler(app);

// @ts-ignore
app.use(function onError(err, req, res, next) {
// The error id is attached to `res.sentry` to be returned
// and optionally displayed to the user for support.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as Sentry from '@sentry/node';

Sentry.init({
environment: 'qa', // dynamic sampling bias to keep transactions
dsn: process.env.E2E_TEST_DSN,
tunnel: `http://localhost:3031/`, // proxy server
tracesSampleRate: 1,
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ test('Should record exceptions captured inside handlers', async ({ request }) =>

test('Should record a transaction for a parameterless route', async ({ request }) => {
const transactionEventPromise = waitForTransaction('esm-loader-node-express-app', transactionEvent => {
console.log('txn', transactionEvent.transaction);
return transactionEvent?.transaction === 'GET /test-success';
});

Expand All @@ -22,9 +21,9 @@ test('Should record a transaction for a parameterless route', async ({ request }
await expect(transactionEventPromise).resolves.toBeDefined();
});

test('Should record a transaction for route with aparameters', async ({ request }) => {
test('Should record a transaction for route with parameters', async ({ request }) => {
const transactionEventPromise = waitForTransaction('esm-loader-node-express-app', transactionEvent => {
return transactionEvent?.transaction === 'GET /test-transaction/:param';
return transactionEvent?.transaction === 'GET /test-transaction/1';
});

await request.get('/test-transaction/1');
Expand Down
1 change: 1 addition & 0 deletions dev-packages/event-proxy-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"fix": "eslint . --format stylish --fix",
"lint": "eslint . --format stylish",
"build": "run-s build:transpile build:types",
"build:tarball": "run-s build:transpile build:types",
"build:dev": "yarn build",
"build:transpile": "rollup -c rollup.npm.config.mjs",
"build:types": "tsc -p tsconfig.types.json",
Expand Down