Unverified Commit 2e67454a authored by OJ Kwon's avatar OJ Kwon Committed by GitHub

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



### What

Pairing PR to https://github.com/vercel/turbo/pull/5714, which I believe last piece to reenable correct datadog test reports for daily next.js integration + turbopack.

1. Creates a unique suite name to avoid collision / merging across different env / grouped test run
2. revert suitename template (which is for _suites_, not _suite_ for top level) as 1 resolves uniqueness
parent 3d569bd9
...@@ -30,9 +30,7 @@ const customJestConfig = { ...@@ -30,9 +30,7 @@ const customJestConfig = {
// This won't count for the retry to avoid duplicated test being reported twice // 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. // - which means our test trace will report test results for the flaky test as failed without retry.
const shouldEnableTestTrace = const shouldEnableTestTrace =
process.env.DATADOG_API_KEY && process.env.DATADOG_API_KEY && process.env.DATADOG_TRACE_NEXTJS_TEST
process.env.DATADOG_TRACE_NEXTJS_TEST &&
!process.env.IS_RETRY
if (shouldEnableTestTrace) { if (shouldEnableTestTrace) {
if (!customJestConfig.reporters) { if (!customJestConfig.reporters) {
...@@ -48,11 +46,6 @@ if (shouldEnableTestTrace) { ...@@ -48,11 +46,6 @@ if (shouldEnableTestTrace) {
'jest-junit', 'jest-junit',
{ {
outputDirectory, 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', reportTestSuiteErrors: 'true',
uniqueOutputName: 'true', uniqueOutputName: 'true',
outputName: 'nextjs-test-junit', outputName: 'nextjs-test-junit',
......
...@@ -278,6 +278,7 @@ async function main() { ...@@ -278,6 +278,7 @@ async function main() {
console.log(`${GROUP}Running tests: console.log(`${GROUP}Running tests:
${testNames.join('\n')} ${testNames.join('\n')}
${ENDGROUP}`) ${ENDGROUP}`)
console.log(`total: ${testNames.length}`)
const hasIsolatedTests = testNames.some((test) => { const hasIsolatedTests = testNames.some((test) => {
return configuredTestTypes.some( return configuredTestTypes.some(
...@@ -365,6 +366,22 @@ ${ENDGROUP}`) ...@@ -365,6 +366,22 @@ ${ENDGROUP}`)
CONTINUOUS_INTEGRATION: '', CONTINUOUS_INTEGRATION: '',
RUN_ID: '', RUN_ID: '',
BUILD_NUMBER: '', 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 ...(isFinalRun
? { ? {
// Events can be finicky in CI. This switches to a more // Events can be finicky in CI. This switches to a more
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment