From cc3952dbfc7d633b5eb0589cf3fa6fb96eb9708e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Antonio=20Fern=C3=A1ndez=20de=20Alba?= Date: Thu, 5 Aug 2021 18:21:38 +0200 Subject: [PATCH] =?UTF-8?q?[ci-app]=C2=A0fix=20this.skip=20(#1550)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/datadog-plugin-mocha/src/index.js | 9 +++++++-- packages/datadog-plugin-mocha/test/index.spec.js | 3 ++- packages/datadog-plugin-mocha/test/mocha-test-skip.js | 6 ++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/datadog-plugin-mocha/src/index.js b/packages/datadog-plugin-mocha/src/index.js index b04661392df..5081978bb5d 100644 --- a/packages/datadog-plugin-mocha/src/index.js +++ b/packages/datadog-plugin-mocha/src/index.js @@ -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) diff --git a/packages/datadog-plugin-mocha/test/index.spec.js b/packages/datadog-plugin-mocha/test/index.spec.js index 420b6714dec..c4edc420ed7 100644 --- a/packages/datadog-plugin-mocha/test/index.spec.js +++ b/packages/datadog-plugin-mocha/test/index.spec.js @@ -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 => { diff --git a/packages/datadog-plugin-mocha/test/mocha-test-skip.js b/packages/datadog-plugin-mocha/test/mocha-test-skip.js index dcb8c6a6263..9c9ad98ec2b 100644 --- a/packages/datadog-plugin-mocha/test/mocha-test-skip.js +++ b/packages/datadog-plugin-mocha/test/mocha-test-skip.js @@ -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() + }) +})