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

Improve nextjs tests flakyness #4411

Merged
merged 8 commits into from
Jun 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions packages/datadog-plugin-next/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,16 @@ describe('Plugin', function () {
})

server.once('error', done)
server.stdout.once('data', () => {
// first log outputted isn't always the server started log
// https://github.com/vercel/next.js/blob/v10.2.0/packages/next/next-server/server/config-utils.ts#L39
// these are webpack related logs that run during execution time and not build

// additionally, next.js sets timeouts in 10.x when displaying extra logs
// https://github.com/vercel/next.js/blob/v10.2.0/packages/next/server/next.ts#L132-L133
setTimeout(done, 700) // relatively high timeout chosen to be safe
})

function waitUntilServerStarted (chunk) {
const chunkString = chunk.toString()
if (chunkString?.includes(port) || chunkString?.includes('Ready ')) {
server.stdout.off('data', waitUntilServerStarted)
done()
}
}
server.stdout.on('data', waitUntilServerStarted)

server.stderr.on('data', chunk => process.stderr.write(chunk))
server.stdout.on('data', chunk => process.stdout.write(chunk))
})
Expand Down
Loading