Skip to content

Commit

Permalink
Improve attempt text
Browse files Browse the repository at this point in the history
  • Loading branch information
Drarig29 committed Sep 10, 2024
1 parent 40c843a commit a388fa5
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`Default reporter resultEnd 1 API test, 1 location, 1 result: success 1`] = `
"✓ [aaa-aaa-aaa] Test name - location: Frankfurt (AWS)
• Total duration: 123 ms - View test run details:
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=1&batch_id=123&from_ci=true[39m[22m
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=1&batch_id=123&from_ci=true[39m[22m
✓ GET - http://fake.url
"
Expand All @@ -12,19 +12,19 @@ exports[`Default reporter resultEnd 1 API test, 1 location, 1 result: success 1`
exports[`Default reporter resultEnd 1 API test, 1 location, 3 results: success, failed non-blocking, failed blocking 1`] = `
"✓ [aaa-aaa-aaa] Test name - location: Frankfurt (AWS)
• Total duration: 123 ms - View test run details:
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=1&batch_id=123&from_ci=true[39m[22m
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=1&batch_id=123&from_ci=true[39m[22m
✓ GET - http://fake.url
✖ [non-blocking] [aaa-aaa-aaa] Test name - location: Frankfurt (AWS)
• Total duration: 123 ms - View test run details:
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=2&batch_id=123&from_ci=true[39m[22m
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=2&batch_id=123&from_ci=true[39m[22m
✖ GET - http://fake.url
 - Assertion failed:
 ▶ responseTime should be less than 1000. Actual: 1234
✖ [blocking] [aaa-aaa-aaa] Test name - location: Frankfurt (AWS)
• Total duration: 123 ms - View test run details:
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=3&batch_id=123&from_ci=true[39m[22m
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=3&batch_id=123&from_ci=true[39m[22m
✖ GET - http://fake.url
 - Assertion failed:
 ▶ responseTime should be less than 1000. Actual: 1234
Expand All @@ -35,7 +35,7 @@ exports[`Default reporter resultEnd 1 API test, 1 location, 3 results: success,
exports[`Default reporter resultEnd 3 API tests, 2 passed (1 from previous CI run) 1`] = `
"✓ [aaa-aaa-aaa] Test name - location: Frankfurt (AWS)
• Total duration: 123 ms - View test run details:
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=1001&batch_id=123&from_ci=true[39m[22m
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=1001&batch_id=123&from_ci=true[39m[22m
✓ GET - http://fake.url
✓ [aaa-aaa-aaa] Test name
Expand All @@ -44,7 +44,7 @@ exports[`Default reporter resultEnd 3 API tests, 2 passed (1 from previous CI ru
✓ (edited) [aaa-aaa-aaa] Test name - location: Frankfurt (AWS)
• Total duration: 123 ms - View test run details:
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=1003&batch_id=123&from_ci=true[39m[22m
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=1003&batch_id=123&from_ci=true[39m[22m
✓ GET - http://fake.url
"
Expand All @@ -53,7 +53,7 @@ exports[`Default reporter resultEnd 3 API tests, 2 passed (1 from previous CI ru
exports[`Default reporter resultEnd 3 Browser tests: failed blocking, timed out, global failure 1`] = `
"✖ [blocking] [abc-def-ghi] Test name - location: Location name - device: chrome.laptop_large
• Total duration: 20000 ms - View test run details:
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/abc-def-ghi/result/1?batch_id=123&from_ci=true[39m[22m
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/abc-def-ghi/result/1?batch_id=123&from_ci=true[39m[22m
 [STEP_TIMEOUT] - Step failed because it took more than 20 seconds.
✓ | 1000ms - Navigate to start URL
https://example.org/
Expand All @@ -72,7 +72,7 @@ exports[`Default reporter resultEnd 3 Browser tests: failed blocking, timed out,
✖ [blocking] [abc-def-ghi] Test name - location: Location name
• View test run details:
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/abc-def-ghi/result/1?batch_id=123&from_ci=true[39m[22m
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/abc-def-ghi/result/1?batch_id=123&from_ci=true[39m[22m
 [FAILURE_CODE] - Failure message
"
Expand All @@ -81,34 +81,34 @@ exports[`Default reporter resultEnd 3 Browser tests: failed blocking, timed out,
exports[`Default reporter resultEnd Incomplete API and Browser tests - passed and failed 1`] = `
"✖ [blocking] [aaa-aaa-aaa] Test name - location: Frankfurt (AWS)
• View test run details:
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=1&batch_id=123&from_ci=true[39m[22m
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=1&batch_id=123&from_ci=true[39m[22m
✖ GET - http://fake.url
✓ [aaa-aaa-aaa] Test name - location: Frankfurt (AWS)
• View test run details:
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=2&batch_id=123&from_ci=true[39m[22m
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=2&batch_id=123&from_ci=true[39m[22m
✓ GET - http://fake.url
✖ [blocking] [bbb-bbb-bbb] Test name - location: Frankfurt (AWS)
• View test run details:
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/bbb-bbb-bbb/result/3?batch_id=123&from_ci=true[39m[22m
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/bbb-bbb-bbb/result/3?batch_id=123&from_ci=true[39m[22m
✓ [bbb-bbb-bbb] Test name - location: Frankfurt (AWS)
• View test run details:
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/bbb-bbb-bbb/result/4?batch_id=123&from_ci=true[39m[22m
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/bbb-bbb-bbb/result/4?batch_id=123&from_ci=true[39m[22m
"
`;

exports[`Default reporter resultEnd Retryable test - Edge case: fails, then retry times out 1`] = `
"[1m[31m✖[39m[22m [[1m[31mblocking[39m[22m] [[1m[2maaa-aaa-aaa[22m[22m] [1mTest name[22m - [1m[31mlocation: [1mFrankfurt (AWS)[22m[1m[39m[22m (attempt 1 of 2)
"[1m[31m✖[39m[22m [[1m[31mblocking[39m[22m] [[1m[2maaa-aaa-aaa[22m[22m] [1mTest name[22m - [1m[31mlocation: [1mFrankfurt (AWS)[22m[1m[39m[22m ([2mattempt 1 of 2, retrying…[22m)
• Total duration: 123 ms - View test run details:
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=0&batch_id=123&from_ci=true[39m[22m
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=0&batch_id=123&from_ci=true[39m[22m
✖ GET - http://fake.url
 - Assertion failed:
 ▶ responseTime should be less than 1000. Actual: 1234
[1m[31m✖[39m[22m [[1m[31mblocking[39m[22m] [[1m[2maaa-aaa-aaa[22m[22m] [1mTest name[22m - [1m[31mlocation: [1mFrankfurt (AWS)[22m[1m[39m[22m (attempt 2 of 2)
[1m[31m✖[39m[22m [[1m[31mblocking[39m[22m] [[1m[2maaa-aaa-aaa[22m[22m] [1mTest name[22m - [1m[31mlocation: [1mFrankfurt (AWS)[22m[1m[39m[22m ([2mattempt 2, success[22m)
• Total duration: 123 ms - View test run details:
⎋ https://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=0&batch_id=123&from_ci=true (previous attempt)
✖ GET - http://fake.url
Expand All @@ -118,39 +118,39 @@ exports[`Default reporter resultEnd Retryable test - Edge case: fails, then retr
`;

exports[`Default reporter resultEnd Retryable test - Usual case: passes after 1 retry only 1`] = `
"[1m[31m✖[39m[22m [[1m[31mblocking[39m[22m] [[1m[2maaa-aaa-aaa[22m[22m] [1mTest name[22m - [1m[31mlocation: [1mFrankfurt (AWS)[22m[1m[39m[22m (attempt 1 of 3)
"[1m[31m✖[39m[22m [[1m[31mblocking[39m[22m] [[1m[2maaa-aaa-aaa[22m[22m] [1mTest name[22m - [1m[31mlocation: [1mFrankfurt (AWS)[22m[1m[39m[22m ([2mattempt 1 of 3, retrying…[22m)
• Total duration: 123 ms - View test run details:
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=0&batch_id=123&from_ci=true[39m[22m
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=0&batch_id=123&from_ci=true[39m[22m
✖ GET - http://fake.url
 - Assertion failed:
 ▶ responseTime should be less than 1000. Actual: 1234
[1m[32m✓[39m[22m [[1m[2maaa-aaa-aaa[22m[22m] [1mTest name[22m - [1m[32mlocation: [1mFrankfurt (AWS)[22m[1m[39m[22m (attempt 2)
[1m[32m✓[39m[22m [[1m[2maaa-aaa-aaa[22m[22m] [1mTest name[22m - [1m[32mlocation: [1mFrankfurt (AWS)[22m[1m[39m[22m ([2mattempt 2, success[22m)
• Total duration: 123 ms - View test run details:
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=1&batch_id=123&from_ci=true[39m[22m
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=1&batch_id=123&from_ci=true[39m[22m
✓ GET - http://fake.url
"
`;

exports[`Default reporter resultEnd Retryable test - Usual case: passes after max retries 1`] = `
"[1m[31m✖[39m[22m [[1m[31mblocking[39m[22m] [[1m[2maaa-aaa-aaa[22m[22m] [1mTest name[22m - [1m[31mlocation: [1mFrankfurt (AWS)[22m[1m[39m[22m (attempt 1 of 3)
"[1m[31m✖[39m[22m [[1m[31mblocking[39m[22m] [[1m[2maaa-aaa-aaa[22m[22m] [1mTest name[22m - [1m[31mlocation: [1mFrankfurt (AWS)[22m[1m[39m[22m ([2mattempt 1 of 3, retrying…[22m)
• Total duration: 123 ms - View test run details:
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=0&batch_id=123&from_ci=true[39m[22m
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=0&batch_id=123&from_ci=true[39m[22m
✖ GET - http://fake.url
 - Assertion failed:
 ▶ responseTime should be less than 1000. Actual: 1234
[1m[31m✖[39m[22m [[1m[31mblocking[39m[22m] [[1m[2maaa-aaa-aaa[22m[22m] [1mTest name[22m - [1m[31mlocation: [1mFrankfurt (AWS)[22m[1m[39m[22m (attempt 2 of 3)
[1m[31m✖[39m[22m [[1m[31mblocking[39m[22m] [[1m[2maaa-aaa-aaa[22m[22m] [1mTest name[22m - [1m[31mlocation: [1mFrankfurt (AWS)[22m[1m[39m[22m ([2mattempt 2 of 3, retrying…[22m)
• Total duration: 123 ms - View test run details:
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=1&batch_id=123&from_ci=true[39m[22m
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=1&batch_id=123&from_ci=true[39m[22m
✖ GET - http://fake.url
 - Assertion failed:
 ▶ responseTime should be less than 1000. Actual: 1234
[1m[32m✓[39m[22m [[1m[2maaa-aaa-aaa[22m[22m] [1mTest name[22m - [1m[32mlocation: [1mFrankfurt (AWS)[22m[1m[39m[22m (attempt 3)
[1m[32m✓[39m[22m [[1m[2maaa-aaa-aaa[22m[22m] [1mTest name[22m - [1m[32mlocation: [1mFrankfurt (AWS)[22m[1m[39m[22m ([2mattempt 3, success[22m)
• Total duration: 123 ms - View test run details:
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=2&batch_id=123&from_ci=true[39m[22m
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=2&batch_id=123&from_ci=true[39m[22m
✓ GET - http://fake.url
"
Expand Down Expand Up @@ -326,7 +326,7 @@ exports[`Default reporter testsWait the spinner text is updated and cleared at t
"View pending summary in Datadog: https://app.datadoghq.com/synthetics/explorer/ci?batchResultId=123
✓ [aaa-aaa-aaa] Test name - location: Frankfurt (AWS)
• Total duration: 123 ms - View test run details:
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=rid&batch_id=123&from_ci=true[39m[22m
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=rid&batch_id=123&from_ci=true[39m[22m
✓ GET - http://fake.url
"
Expand All @@ -336,7 +336,7 @@ exports[`Default reporter testsWait the spinner text is updated and cleared at t
"View pending summary in Datadog: https://app.datadoghq.com/synthetics/explorer/ci?batchResultId=123
✓ [aaa-aaa-aaa] Test name - location: Frankfurt (AWS)
• Total duration: 123 ms - View test run details:
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=rid&batch_id=123&from_ci=true[39m[22m
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=rid&batch_id=123&from_ci=true[39m[22m
✓ GET - http://fake.url
⠙ Waiting for 1 test (aaa-aaa-aaa)…
Expand All @@ -347,7 +347,7 @@ exports[`Default reporter testsWait the spinner text is updated and cleared at t
"View pending summary in Datadog: https://app.datadoghq.com/synthetics/explorer/ci?batchResultId=123
✓ [aaa-aaa-aaa] Test name - location: Frankfurt (AWS)
• Total duration: 123 ms - View test run details:
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=rid&batch_id=123&from_ci=true[39m[22m
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=rid&batch_id=123&from_ci=true[39m[22m
✓ GET - http://fake.url
⠹ Waiting for the batch to end…
"
Expand All @@ -368,7 +368,7 @@ exports[`Default reporter testsWait the spinner text is updated and cleared at t
✓ [aaa-aaa-aaa] Test name - location: Frankfurt (AWS)
• Total duration: 123 ms - View test run details:
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=rid&batch_id=123&from_ci=true[39m[22m
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=rid&batch_id=123&from_ci=true[39m[22m
✓ GET - http://fake.url
"
Expand All @@ -381,7 +381,7 @@ exports[`Default reporter testsWait the spinner text is updated and cleared at t
✓ [aaa-aaa-aaa] Test name - location: Frankfurt (AWS)
• Total duration: 123 ms - View test run details:
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=rid&batch_id=123&from_ci=true[39m[22m
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=rid&batch_id=123&from_ci=true[39m[22m
✓ GET - http://fake.url
- Waiting for 1 test (aaa-aaa-aaa)…
Expand All @@ -398,7 +398,7 @@ exports[`Default reporter testsWait the spinner text is updated and cleared at t
✓ [aaa-aaa-aaa] Test name - location: Frankfurt (AWS)
• Total duration: 123 ms - View test run details:
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=rid&batch_id=123&from_ci=true[39m[22m
⎋ [2m[36mhttps://app.datadoghq.com/synthetics/details/aaa-aaa-aaa?resultId=rid&batch_id=123&from_ci=true[39m[22m
✓ GET - http://fake.url
- Waiting for 1 test (aaa-aaa-aaa)…
Expand Down
23 changes: 13 additions & 10 deletions src/commands/synthetics/reporters/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ const renderExecutionResult = (test: Test, execution: Result, baseUrl: string, b
const resultUrlStatus = getResultUrlSuffix(execution)

outputLines.push(` •${durationText} View test run details:`)
outputLines.push(` ⎋ ${chalk.dim.cyan(resultUrl)} ${resultUrlStatus}`)
outputLines.push(` ⎋ ${chalk.dim.cyan(resultUrl)}${resultUrlStatus}`)
}

if (isResultSkippedBySelectiveRerun(execution)) {
Expand Down Expand Up @@ -267,11 +267,11 @@ export const getResultUrlSuffix = (execution: Result) => {
const timedOutRetry = isTimedOutRetry(retries, maxRetries, timedOut)

if (timedOutRetry) {
return '(previous attempt)'
return ' (previous attempt)'
}

if (timedOut) {
return '(not yet received)'
return ' (not yet received)'
}
}

Expand All @@ -292,17 +292,20 @@ const getAttemptSuffix = (passed: boolean, retries: number, maxRetries: number,
return ''
}

if (isTimedOutRetry(retries, maxRetries, timedOut)) {
// Current attempt is still that of the last received result, so we increment it to refer to the expected retry.
return ` (attempt ${currentAttempt + 1} of ${maxAttempts})`
const attempt = (current: number, max: number) => {
if (!passed && current < max) {
return chalk.dim(`attempt ${current} of ${max}, retrying…`)
}

return chalk.dim(`attempt ${current}, success`)
}

if (passed) {
// Having 'of' for a passed result is redundant, and is confusing when we have "✅ attempt 1 of 2".
return ` (attempt ${currentAttempt})`
if (isTimedOutRetry(retries, maxRetries, timedOut)) {
// Current attempt is still that of the last received result, so we increment it to refer to the expected retry.
return ` (${attempt(currentAttempt + 1, maxAttempts)})`
}

return ` (attempt ${currentAttempt} of ${maxAttempts})`
return ` (${attempt(currentAttempt, maxAttempts)})`
}

const getResultIconAndColor = (resultOutcome: ResultOutcome): [string, chalk.Chalk] => {
Expand Down

0 comments on commit a388fa5

Please sign in to comment.