Skip to content

Commit

Permalink
Add additional assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
lforst committed Aug 31, 2022
1 parent 663f765 commit b8c734e
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 3 deletions.
6 changes: 4 additions & 2 deletions packages/nextjs/test/integration/next.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
const { withSentryConfig } = require('@sentry/nextjs');

// NOTE: This will be used by integration tests to distinguish between Webpack 4 and Webpack 5
const moduleExports = {
eslint: {
ignoreDuringBuilds: true,
future: {
webpack5: false,
},
sentry: {
experiments: { autoWrapDataFetchers: true },
},
};

const SentryWebpackPluginOptions = {
dryRun: true,
silent: true,
Expand Down
16 changes: 16 additions & 0 deletions packages/nextjs/test/integration/next.config.js.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { withSentryConfig } = require('@sentry/nextjs');

const moduleExports = {
eslint: {
ignoreDuringBuilds: true,
},
sentry: {
experiments: { autoWrapDataFetchers: true },
},
};
const SentryWebpackPluginOptions = {
dryRun: true,
silent: true,
};

module.exports = withSentryConfig(moduleExports, SentryWebpackPluginOptions);
2 changes: 1 addition & 1 deletion packages/nextjs/test/integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"dependencies": {
"@sentry/nextjs": "file:../../",
"next": "latest",
"next": "11.x",
"react": "^17.0.1",
"react-dom": "^17.0.1"
},
Expand Down
37 changes: 37 additions & 0 deletions packages/nextjs/test/integration/package.json.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "with-typescript",
"license": "BSD-3-Clause",
"scripts": {
"dev": "next",
"build": "next build",
"predebug": "source ../integration_test_utils.sh && link_monorepo_packages '../../..' && yarn build",
"start": "next start"
},
"dependencies": {
"@sentry/nextjs": "file:../../",
"next": "latest",
"react": "^17.0.1",
"react-dom": "^17.0.1"
},
"devDependencies": {
"@types/node": "^15.3.1",
"@types/puppeteer": "^5.4.3",
"@types/react": "17.0.47",
"@types/react-dom": "17.0.17",
"nock": "^13.1.0",
"puppeteer": "^9.1.1",
"typescript": "^4.2.4",
"yargs": "^16.2.0"
},
"resolutions": {
"@sentry/browser": "file:../../../browser",
"@sentry/core": "file:../../../core",
"@sentry/hub": "file:../../../hub",
"@sentry/integrations": "file:../../../integrations",
"@sentry/node": "file:../../../node",
"@sentry/react": "file:../../../react",
"@sentry/tracing": "file:../../../tracing",
"@sentry/types": "file:../../../types",
"@sentry/utils": "file:../../../utils"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ module.exports = async ({ page, url, requests }) => {
'Returned data must contain original data returned from getInitialProps.',
);

assert.ok(nextDataTagValue.props.pageProps._sentryTraceData, '_sentryTraceData must exist in __NEXT_DATA__ tag');
assert.ok(nextDataTagValue.props.pageProps._sentryBaggage, '_sentryBaggage must exist in __NEXT_DATA__ tag');

assert.strictEqual(
nextDataTagValue.props.pageProps._sentryTraceData.split('-')[0],
transactionEnvelope.envelopeHeader.trace.trace_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ module.exports = async ({ page, url, requests }) => {
'Returned data must contain original data returned from getServerSideProps.',
);

assert.ok(nextDataTagValue.props.pageProps._sentryTraceData, '_sentryTraceData must exist in __NEXT_DATA__ tag');
assert.ok(nextDataTagValue.props.pageProps._sentryBaggage, '_sentryBaggage must exist in __NEXT_DATA__ tag');

assert.strictEqual(
nextDataTagValue.props.pageProps._sentryTraceData.split('-')[0],
transactionEnvelope.envelopeHeader.trace.trace_id,
Expand Down

0 comments on commit b8c734e

Please sign in to comment.