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

test(ci): refine test suite name unique #54013

Merged
merged 2 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
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
9 changes: 1 addition & 8 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ const customJestConfig = {
// This won't count for the retry to avoid duplicated test being reported twice
// - which means our test trace will report test results for the flaky test as failed without retry.
const shouldEnableTestTrace =
process.env.DATADOG_API_KEY &&
process.env.DATADOG_TRACE_NEXTJS_TEST &&
!process.env.IS_RETRY
process.env.DATADOG_API_KEY && process.env.DATADOG_TRACE_NEXTJS_TEST

if (shouldEnableTestTrace) {
if (!customJestConfig.reporters) {
Expand All @@ -48,11 +46,6 @@ if (shouldEnableTestTrace) {
'jest-junit',
{
outputDirectory,
// note: {filename} is not a full path, since putting full path
// makes suite name too long and truncates and not able to read the suite name
suiteNameTemplate: `{title} [${process.env.NEXT_TEST_MODE ?? 'default'}${
process.env.TURBOPACK ? '/t' : ''
}${process.env.EXPERIMENTAL_TURBOPACK ? '/et' : ''}/{filename}]`,
reportTestSuiteErrors: 'true',
uniqueOutputName: 'true',
outputName: 'nextjs-test-junit',
Expand Down
17 changes: 17 additions & 0 deletions run-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ async function main() {
console.log(`${GROUP}Running tests:
${testNames.join('\n')}
${ENDGROUP}`)
console.log(`total: ${testNames.length}`)

const hasIsolatedTests = testNames.some((test) => {
return configuredTestTypes.some(
Expand Down Expand Up @@ -365,6 +366,22 @@ ${ENDGROUP}`)
CONTINUOUS_INTEGRATION: '',
RUN_ID: '',
BUILD_NUMBER: '',
// Format the output of junit report to include the test name
// For the debugging purpose to compare actual run list to the generated reports
// [NOTE]: This won't affect if junit reporter is not enabled
JEST_JUNIT_OUTPUT_NAME:
test && test.length > 0 ? test.replaceAll('/', '_') : undefined,
// Specify suite name for the test to avoid unexpected merging across different env / grouped tests
// This is not individual suites name (corresponding 'describe'), top level suite name which have redundant names by default
// [NOTE]: This won't affect if junit reporter is not enabled
JEST_SUITE_NAME: [
`${process.env.NEXT_TEST_MODE ?? 'default'}`,
groupArg,
testType,
test,
]
.filter(Boolean)
.join(':'),
...(isFinalRun
? {
// Events can be finicky in CI. This switches to a more
Expand Down
Loading