diff --git a/.vscode/launch.json b/.vscode/launch.json index a0a7d18de2e2..f1e4a2249a26 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -51,17 +51,17 @@ // @sentry/nextjs - Run a specific integration test file - // Must have file in currently active tab when hitting the play button + // Must have test file in currently active tab when hitting the play button, and must already have run `yarn` in test app directory { "name": "Debug @sentry/nextjs integration tests - just open file", "type": "node", "cwd": "${workspaceFolder}/packages/nextjs", "request": "launch", - // TODO create a build task - // "preLaunchTask": "yarn build", - - // this is going straight to `server.js` (rather than running the tests through yarn) in order to be able to skip - // having to reinstall dependencies on every new test run + // since we're not using the normal test runner, we need to make sure we're using the current version of all local + // SDK packages and then manually rebuild the test app + "preLaunchTask": "Prepare nextjs integration test app for debugging", + // running `server.js` directly (rather than running the tests through yarn) allows us to skip having to reinstall + // dependencies on every new test run "program": "${workspaceFolder}/packages/nextjs/test/integration/test/server.js", "args": [ "--debug", @@ -69,10 +69,29 @@ "--filter", "${fileBasename}" ], - "sourceMaps": true, + "skipFiles": [ - "/**", "**/tslib/**" + "/**", + // this prevents us from landing in a neverending cycle of TS async-polyfill functions as we're stepping through + // our code + "${workspaceFolder}/node_modules/tslib/**/*" ], + "sourceMaps": true, + // this controls which files are sourcemapped + "outFiles": [ + // our SDK code + "${workspaceFolder}/**/dist/**/*.js", + // the built test app + "${workspaceFolder}/packages/nextjs/test/integration/.next/**/*.js", + "!**/node_modules/**" + ], + "resolveSourceMapLocations": [ + "${workspaceFolder}/**/dist/**", + "${workspaceFolder}/packages/nextjs/test/integration/.next/**", + "!**/node_modules/**" + ], + "internalConsoleOptions": "openOnSessionStart" + }, ] } diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 000000000000..6e797a064c61 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,13 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 for documentation about `tasks.json` syntax + "version": "2.0.0", + "tasks": [ + { + "label": "Prepare nextjs integration test app for VSCode debugger", + "type": "npm", + "script": "predebug", + "path": "packages/nextjs/test/integration/", + "detail": "Link the SDK (if not already linked) and build test app" + } + ] +} diff --git a/packages/nextjs/test/integration/package.json b/packages/nextjs/test/integration/package.json index cd117b39ec31..5523ee933d20 100644 --- a/packages/nextjs/test/integration/package.json +++ b/packages/nextjs/test/integration/package.json @@ -4,6 +4,7 @@ "scripts": { "dev": "next", "build": "next build", + "predebug": "source ../integration_test_utils.sh && link_monorepo_packages '../../..' && yarn build", "start": "next start" }, "dependencies": { diff --git a/packages/nextjs/test/integration/pages/api/http/index.ts b/packages/nextjs/test/integration/pages/api/http/index.ts index 5804f79bb085..958dc09ad6f6 100644 --- a/packages/nextjs/test/integration/pages/api/http/index.ts +++ b/packages/nextjs/test/integration/pages/api/http/index.ts @@ -3,7 +3,9 @@ import { get } from 'http'; import { NextApiRequest, NextApiResponse } from 'next'; const handler = async (_req: NextApiRequest, res: NextApiResponse): Promise => { + // make an outgoing request in order to test that the `Http` integration creates a span await new Promise(resolve => get('http://example.com', resolve)); + res.status(200).json({}); }; diff --git a/packages/nextjs/test/integration/pages/fetch.tsx b/packages/nextjs/test/integration/pages/fetch.tsx index 44e0a4ceb68d..1b538c936494 100644 --- a/packages/nextjs/test/integration/pages/fetch.tsx +++ b/packages/nextjs/test/integration/pages/fetch.tsx @@ -1,6 +1,7 @@ const ButtonPage = (): JSX.Element => (