Skip to content

Commit bec58e0

Browse files
author
Luca Forstner
committed
Clean up setUpNextPage test helper
1 parent 651e8e0 commit bec58e0

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

packages/nextjs/test/performance/client.test.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { getGlobalObject } from '@sentry/utils';
22
import { JSDOM } from 'jsdom';
3+
import { NEXT_DATA as NextData } from 'next/dist/next-server/lib/utils';
34
import { default as Router } from 'next/router';
45

56
import { nextRouterInstrumentation } from '../../src/performance/client';
@@ -40,23 +41,23 @@ describe('client', () => {
4041
props: any;
4142
hasNextData: boolean;
4243
}) {
44+
const nextDataContent: NextData = {
45+
props: pageProperties.props,
46+
page: pageProperties.route,
47+
query: pageProperties.query,
48+
buildId: 'y76hvndNJBAithejdVGLW',
49+
isFallback: false,
50+
gssp: true,
51+
appGip: true,
52+
scriptLoader: [],
53+
};
54+
4355
const dom = new JSDOM(
4456
// Just some example what a __NEXT_DATA__ tag might look like
4557
pageProperties.hasNextData
46-
? `<body>
47-
<script id="__NEXT_DATA__" type="application/json">
48-
{
49-
"props": ${JSON.stringify(pageProperties.props)},
50-
"page": "${pageProperties.route}",
51-
"query": ${JSON.stringify(pageProperties.query)},
52-
"buildId": "y76hvndNJBAithejdVGLW",
53-
"isFallback": false,
54-
"gssp": true,
55-
"appGip": true,
56-
"scriptLoader": []
57-
}
58-
</script>
59-
</body>`
58+
? `<body><script id="__NEXT_DATA__" type="application/json">${JSON.stringify(
59+
nextDataContent,
60+
)}</script></body>`
6061
: '<body><h1>No next data :(</h1></body>',
6162
{ url: pageProperties.url },
6263
);

0 commit comments

Comments
 (0)