Skip to content

Commit 0ecbf36

Browse files
[test optimization] Migrate cucumber plugin tests to integration tests (#6923)
1 parent d5805b3 commit 0ecbf36

File tree

5 files changed

+2345
-2654
lines changed

5 files changed

+2345
-2654
lines changed

.github/workflows/test-optimization.yml

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,31 @@ jobs:
116116
NODE_OPTIONS: '-r ./ci/init'
117117
JEST_VERSION: ${{ matrix.jest-version }}
118118

119-
integration-ci:
119+
integration-cucumber:
120+
strategy:
121+
matrix:
122+
version: [oldest, latest]
123+
cucumber-version: [7.0.0, latest]
124+
runs-on: ubuntu-latest
125+
env:
126+
DD_SERVICE: dd-trace-js-integration-tests
127+
DD_CIVISIBILITY_AGENTLESS_ENABLED: 1
128+
DD_API_KEY: ${{ secrets.DD_API_KEY }}
129+
steps:
130+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
131+
- uses: ./.github/actions/node
132+
with:
133+
version: ${{ matrix.version }}
134+
- uses: ./.github/actions/install
135+
- run: yarn test:integration:cucumber
136+
env:
137+
NODE_OPTIONS: '-r ./ci/init'
138+
CUCUMBER_VERSION: ${{ matrix.cucumber-version }}
139+
140+
integration-selenium:
120141
strategy:
121142
matrix:
122143
version: [oldest, latest]
123-
framework: [cucumber, selenium]
124144
runs-on: ubuntu-latest
125145
env:
126146
DD_SERVICE: dd-trace-js-integration-tests
@@ -140,7 +160,6 @@ jobs:
140160
sudo apt-get update
141161
sudo apt-get install -y google-chrome-stable
142162
if [ $? -ne 0 ]; then echo "Failed to install Google Chrome"; exit 1; fi
143-
if: ${{ matrix.framework == 'selenium' }}
144163
- name: Install ChromeDriver
145164
run: |
146165
export CHROME_VERSION=$(google-chrome --version)
@@ -150,9 +169,8 @@ jobs:
150169
unzip chromedriver-linux64.zip
151170
sudo mv chromedriver-linux64/chromedriver /usr/bin/chromedriver
152171
sudo chmod +x /usr/bin/chromedriver
153-
if: ${{ matrix.framework == 'selenium' }}
154172
- uses: ./.github/actions/install
155-
- run: yarn test:integration:${{ matrix.framework }}
173+
- run: yarn test:integration:selenium
156174
env:
157175
NODE_OPTIONS: '-r ./ci/init'
158176

@@ -204,13 +222,3 @@ jobs:
204222
- run: yarn test:integration:vitest
205223
env:
206224
NODE_OPTIONS: '-r ./ci/init'
207-
208-
plugin-cucumber:
209-
runs-on: ubuntu-latest
210-
env:
211-
PLUGINS: cucumber
212-
steps:
213-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
214-
- uses: ./.github/actions/plugins/test
215-
with:
216-
dd_api_key: ${{ secrets.DD_API_KEY }}

packages/datadog-plugin-cucumber/test/features/simple.js renamed to integration-tests/ci-visibility/cucumber-plugin-tests/features/support/steps.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
'use strict'
22

33
const { Before, Given, When, Then, setWorldConstructor } = require('@cucumber/cucumber')
4-
const { expect } = require('chai')
4+
const assert = require('assert')
5+
6+
const ENDPOINT_URL = process.env.DD_CIVISIBILITY_AGENTLESS_URL ||
7+
`http://127.0.0.1:${process.env.DD_TRACE_AGENT_PORT}`
58

69
const CustomWorld = function () {
710
this.datadog = 0
@@ -31,18 +34,18 @@ When('run', () => {})
3134
When('integration', function () {
3235
const http = require('http')
3336
return new Promise(resolve => {
34-
http.request('http://test:123', () => {
37+
http.request(`${ENDPOINT_URL}/info`, { agent: false }, () => {
3538
resolve()
3639
}).end()
3740
})
3841
})
3942

4043
Then('pass', function () {
41-
expect(this.datadog).to.eql('datadog')
44+
assert.equal(this.datadog, 'datadog')
4245
})
4346

4447
Then('fail', function () {
45-
expect(this.datadog).to.eql('godatad')
48+
assert.equal(this.datadog, 'godatad')
4649
})
4750

4851
Then('skip', function () {

0 commit comments

Comments
 (0)