Skip to content

Commit

Permalink
Add serverside integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lforst committed Aug 31, 2022
1 parent 5a76709 commit 663f765
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const {
const assert = require('assert').strict;

module.exports = async ({ page, url, requests }) => {
await page.goto(`${url}/withInitialProps`);
await page.goto(`${url}/42/withInitialProps`);
await page.waitForRequest(isTransactionRequest);

const transactionEnvelope = extractEnvelopeFromRequest(requests.transactions[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const {
const assert = require('assert').strict;

module.exports = async ({ page, url, requests }) => {
await page.goto(`${url}/withServerSideProps`);
await page.goto(`${url}/1337/withServerSideProps`);
await page.waitForRequest(isTransactionRequest);

const transactionEnvelope = extractEnvelopeFromRequest(requests.transactions[0]);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const assert = require('assert');

const { sleep } = require('../utils/common');
const { getAsync, interceptTracingRequest } = require('../utils/server');

module.exports = async ({ url: urlBase, argv }) => {
const url = `${urlBase}/239/withInitialProps`;

const capturedRequest = interceptTracingRequest(
{
contexts: {
trace: {
op: 'nextjs.data.server',
},
},
transaction: '/[id]/withInitialProps',
transaction_info: {
source: 'route',
},
type: 'transaction',
request: {
url,
},
},
argv,
'tracingGetInitialProps',
);

await getAsync(url);
await sleep(250);

assert.ok(capturedRequest.isDone(), 'Did not intercept expected request');
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const assert = require('assert');

const { sleep } = require('../utils/common');
const { getAsync, interceptTracingRequest } = require('../utils/server');

module.exports = async ({ url: urlBase, argv }) => {
const url = `${urlBase}/193/withServerSideProps`;

const capturedRequest = interceptTracingRequest(
{
contexts: {
trace: {
op: 'nextjs.data.server',
},
},
transaction: '/[id]/withServerSideProps',
transaction_info: {
source: 'route',
},
type: 'transaction',
request: {
url,
},
},
argv,
'tracingServerGetServerSideProps',
);

await getAsync(url);
await sleep(250);

assert.ok(capturedRequest.isDone(), 'Did not intercept expected request');
};

0 comments on commit 663f765

Please sign in to comment.