Skip to content

Commit a4780da

Browse files
Mariovidowatson
authored andcommitted
[test-optimization] [SDTEST-2290] Fix support for Cucumber 12+ (#6087)
1 parent a42029e commit a4780da

File tree

6 files changed

+31
-25
lines changed

6 files changed

+31
-25
lines changed

.github/workflows/test-optimization.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,8 @@ jobs:
7575
integration-ci:
7676
strategy:
7777
matrix:
78-
# TODO: Add cucumber and selenium once cucumber+12 is fixed
7978
version: [oldest, latest]
80-
framework: [jest, mocha]
79+
framework: [cucumber, selenium, jest, mocha]
8180
runs-on: ubuntu-latest
8281
env:
8382
DD_SERVICE: dd-trace-js-integration-tests
@@ -161,14 +160,13 @@ jobs:
161160
env:
162161
NODE_OPTIONS: '-r ./ci/init'
163162

164-
# TODO: Remove comment once cucumber+12 is fixed
165-
# plugin-cucumber:
166-
# runs-on: ubuntu-latest
167-
# env:
168-
# PLUGINS: cucumber
169-
# steps:
170-
# - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
171-
# - uses: ./.github/actions/plugins/test
163+
plugin-cucumber:
164+
runs-on: ubuntu-latest
165+
env:
166+
PLUGINS: cucumber
167+
steps:
168+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
169+
- uses: ./.github/actions/plugins/test
172170

173171
# TODO: fix performance issues and test more Node versions
174172
plugin-cypress:

integration-tests/ci-visibility/automatic-log-submission.spec.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const {
1111
} = require('../helpers')
1212
const { FakeCiVisIntake } = require('../ci-visibility-intake')
1313
const webAppServer = require('./web-app-server')
14+
const { NODE_MAJOR } = require('../../version')
1415

1516
describe('test visibility automatic log submission', () => {
1617
let sandbox, cwd, receiver, childProcess, webAppPort
@@ -59,11 +60,10 @@ describe('test visibility automatic log submission', () => {
5960
name: 'jest',
6061
command: 'node ./node_modules/jest/bin/jest --config ./ci-visibility/automatic-log-submission/config-jest.js'
6162
},
62-
// TODO: Uncomment once cucumber+12 is fixed
63-
// {
64-
// name: 'cucumber',
65-
// command: './node_modules/.bin/cucumber-js ci-visibility/automatic-log-submission-cucumber/*.feature'
66-
// },
63+
{
64+
name: 'cucumber',
65+
command: './node_modules/.bin/cucumber-js ci-visibility/automatic-log-submission-cucumber/*.feature'
66+
},
6767
{
6868
name: 'playwright',
6969
command: './node_modules/.bin/playwright test -c playwright.config.js',
@@ -76,6 +76,8 @@ describe('test visibility automatic log submission', () => {
7676
]
7777

7878
testFrameworks.forEach(({ name, command, getExtraEnvVars = () => ({}) }) => {
79+
if ((NODE_MAJOR === 18 || NODE_MAJOR === 23) && name === 'cucumber') return
80+
7981
context(`with ${name}`, () => {
8082
it('can automatically submit logs', (done) => {
8183
let logIds, testIds

integration-tests/cucumber/cucumber.spec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ const {
6363
DD_CAPABILITIES_IMPACTED_TESTS
6464
} = require('../../packages/dd-trace/src/plugins/util/test')
6565
const { DD_HOST_CPU_COUNT } = require('../../packages/dd-trace/src/plugins/util/env')
66+
const { NODE_MAJOR } = require('../../version')
6667

6768
const versions = ['7.0.0', 'latest']
6869

@@ -74,6 +75,8 @@ const featuresPath = 'ci-visibility/features/'
7475
const fileExtension = 'js'
7576

7677
versions.forEach(version => {
78+
if ((NODE_MAJOR === 18 || NODE_MAJOR === 23) && version === 'latest') return
79+
7780
// TODO: add esm tests
7881
describe(`cucumber@${version} commonJS`, () => {
7982
let sandbox, cwd, receiver, childProcess, testOutput

integration-tests/selenium/selenium.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const {
1717
TEST_IS_RUM_ACTIVE,
1818
TEST_TYPE
1919
} = require('../../packages/dd-trace/src/plugins/util/test')
20+
const { NODE_MAJOR } = require('../../version')
2021

2122
const webAppServer = require('../ci-visibility/web-app-server')
2223

@@ -74,6 +75,7 @@ versionRange.forEach(version => {
7475
}
7576
]
7677
testFrameworks.forEach(({ name, command }) => {
78+
if ((NODE_MAJOR === 18 || NODE_MAJOR === 23) && name === 'cucumber') return
7779
context(`with ${name}`, () => {
7880
it('identifies tests using selenium as browser tests', (done) => {
7981
const assertionPromise = receiver

packages/datadog-instrumentations/src/cucumber.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const {
4343
CUCUMBER_WORKER_TRACE_PAYLOAD_CODE,
4444
getIsFaultyEarlyFlakeDetection
4545
} = require('../../dd-trace/src/plugins/util/test')
46+
const satisfies = require('semifies')
4647

4748
const isMarkedAsUnskippable = (pickle) => {
4849
return pickle.tags.some(tag => tag.name === '@datadog:unskippable')
@@ -224,7 +225,7 @@ function getPickleByFile (runtimeOrCoodinator) {
224225
}, {})
225226
}
226227

227-
function wrapRun (pl, isLatestVersion) {
228+
function wrapRun (pl, isLatestVersion, version) {
228229
if (patched.has(pl)) return
229230

230231
patched.add(pl)
@@ -398,9 +399,10 @@ function wrapRun (pl, isLatestVersion) {
398399
const promise = runStep.apply(this, arguments)
399400

400401
promise.then((result) => {
401-
const { status, skipReason, errorMessage } = isLatestVersion
402-
? getStatusFromResultLatest(result)
403-
: getStatusFromResult(result)
402+
const finalResult = satisfies(version, '>=12.0.0') ? result.result : result
403+
const getStatus = satisfies(version, '>=7.3.0') ? getStatusFromResultLatest : getStatusFromResult
404+
405+
const { status, skipReason, errorMessage } = getStatus(finalResult)
404406

405407
testFinishCh.publish({ isStep: true, status, skipReason, errorMessage, ...ctx.currentStore })
406408
})
@@ -415,18 +417,18 @@ function wrapRun (pl, isLatestVersion) {
415417
})
416418
}
417419

418-
function pickleHook (PickleRunner) {
420+
function pickleHook (PickleRunner, version) {
419421
const pl = PickleRunner.default
420422

421-
wrapRun(pl, false)
423+
wrapRun(pl, false, version)
422424

423425
return PickleRunner
424426
}
425427

426-
function testCaseHook (TestCaseRunner) {
428+
function testCaseHook (TestCaseRunner, version) {
427429
const pl = TestCaseRunner.default
428430

429-
wrapRun(pl, true)
431+
wrapRun(pl, true, version)
430432

431433
return TestCaseRunner
432434
}

scripts/verify-ci-config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,7 @@ checkPlugins(path.join(__dirname, '..', '.github', 'workflows', 'test-optimizati
150150
.filter(file => fs.existsSync(path.join(__dirname, '..', 'packages', file, 'test')))
151151
.map(file => file.replace('datadog-plugin-', ''))
152152
for (const plugin of allPlugins) {
153-
// TODO: Remove check of cucumber once cucumber+12 is fixed
154-
if (!allTestedPlugins.has(plugin) && plugin !== 'cucumber') {
153+
if (!allTestedPlugins.has(plugin)) {
155154
pluginErrorMsg(plugin, 'ERROR', 'Plugin is tested but not in at least one GitHub workflow')
156155
}
157156
}

0 commit comments

Comments
 (0)