Skip to content

Commit b046c06

Browse files
[test optimization] Fix wrong log.error if quarantined tests are empty (#5296)
1 parent 996e8fb commit b046c06

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

  • packages/datadog-instrumentations/src

packages/datadog-instrumentations/src/jest.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
170170
try {
171171
const hasQuarantinedTests = !!quarantinedTests.jest
172172
this.quarantinedTestsForThisSuite = hasQuarantinedTests
173-
? this.getQuarantinedTestsForSuite(quarantinedTests.jest.suites[this.testSuite].tests)
173+
? this.getQuarantinedTestsForSuite(quarantinedTests.jest.suites?.[this.testSuite]?.tests)
174174
: this.getQuarantinedTestsForSuite(this.testEnvironmentOptions._ddQuarantinedTests)
175175
} catch (e) {
176176
log.error('Error parsing quarantined tests', e)
@@ -209,11 +209,14 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
209209
return knownTestsForSuite
210210
}
211211

212-
getQuarantinedTestsForSuite (quaratinedTests) {
212+
getQuarantinedTestsForSuite (quarantined) {
213213
if (this.quarantinedTestsForThisSuite) {
214214
return this.quarantinedTestsForThisSuite
215215
}
216-
let quarantinedTestsForSuite = quaratinedTests
216+
if (!quarantined) {
217+
return []
218+
}
219+
let quarantinedTestsForSuite = quarantined
217220
// If jest is using workers, quarantined tests are serialized to json.
218221
// If jest runs in band, they are not.
219222
if (typeof quarantinedTestsForSuite === 'string') {

0 commit comments

Comments
 (0)