Skip to content

Commit

Permalink
[ci-app] fix this.skip (DataDog#1550)
Browse files Browse the repository at this point in the history
  • Loading branch information
juan-fernandez authored Aug 5, 2021
1 parent 9d2d267 commit cc3952d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
9 changes: 7 additions & 2 deletions packages/datadog-plugin-mocha/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,13 @@ function createWrapRunTest (tracer, testEnvironmentMetadata, sourceRoot) {
activeSpan.setTag(TEST_STATUS, 'fail')
}
} catch (error) {
activeSpan.setTag(TEST_STATUS, 'fail')
activeSpan.setTag('error', error)
// this.skip has been called
if (error.constructor.name === 'Pending' && !this.forbidPending) {
activeSpan.setTag(TEST_STATUS, 'skip')
} else {
activeSpan.setTag(TEST_STATUS, 'fail')
activeSpan.setTag('error', error)
}
throw error
} finally {
finishAllTraceSpans(activeSpan)
Expand Down
3 changes: 2 additions & 1 deletion packages/datadog-plugin-mocha/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ describe('Plugin', () => {
const testNames = [
'mocha-test-skip can skip',
'mocha-test-skip-different can skip too',
'mocha-test-skip-different can skip twice'
'mocha-test-skip-different can skip twice',
'mocha-test-programmatic-skip can skip too'
]
const assertionPromises = testNames.map(testName => {
return agent.use(trace => {
Expand Down
6 changes: 6 additions & 0 deletions packages/datadog-plugin-mocha/test/mocha-test-skip.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ describe('mocha-test-skip-different', () => {
expect(true).to.equal(false)
})
})

describe('mocha-test-programmatic-skip', () => {
it('can skip too', function () {
this.skip()
})
})

0 comments on commit cc3952d

Please sign in to comment.