Skip to content

Commit 598409d

Browse files
[test optimization] Deprecate dd-trace support for cypress <10.2.0
1 parent 0bffaa1 commit 598409d

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

integration-tests/cypress/cypress.spec.js

+36
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,42 @@ moduleTypes.forEach(({
113113
await receiver.stop()
114114
})
115115

116+
if (version === '6.7.0') {
117+
// to be removed when we drop support for [email protected]
118+
it('logs a warning if using a deprecated version of cypress', (done) => {
119+
let stdout = ''
120+
const {
121+
NODE_OPTIONS,
122+
...restEnvVars
123+
} = getCiVisEvpProxyConfig(receiver.port)
124+
125+
childProcess = exec(
126+
`${testCommand} --spec cypress/e2e/spec.cy.js`,
127+
{
128+
cwd,
129+
env: {
130+
...restEnvVars,
131+
CYPRESS_BASE_URL: `http://localhost:${webAppPort}`
132+
},
133+
stdio: 'pipe'
134+
}
135+
)
136+
137+
childProcess.stdout.on('data', (chunk) => {
138+
stdout += chunk.toString()
139+
})
140+
141+
childProcess.on('exit', () => {
142+
assert.include(
143+
stdout,
144+
'WARNING: dd-trace support for Cypress<10.2.0 is deprecated' +
145+
' and will not be supported in future versions of dd-trace.'
146+
)
147+
done()
148+
})
149+
})
150+
}
151+
116152
it('does not crash if badly init', (done) => {
117153
const {
118154
NODE_OPTIONS, // NODE_OPTIONS dd-trace config does not work with cypress

packages/datadog-plugin-cypress/src/plugin.js

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const NoopTracer = require('../../dd-trace/src/noop/tracer')
22
const cypressPlugin = require('./cypress-plugin')
3+
const satisfies = require('semifies')
34

45
const noopTask = {
56
'dd:testSuiteStart': () => {
@@ -19,6 +20,15 @@ const noopTask = {
1920
module.exports = (on, config) => {
2021
const tracer = require('../../dd-trace')
2122

23+
if (satisfies(config.version, '<10.2.0')) {
24+
// console.warn does not seem to work in cypress, so using console.log instead
25+
// eslint-disable-next-line no-console
26+
console.log(
27+
'WARNING: dd-trace support for Cypress<10.2.0 is deprecated' +
28+
' and will not be supported in future versions of dd-trace.'
29+
)
30+
}
31+
2232
// The tracer was not init correctly for whatever reason (such as invalid DD_SITE)
2333
if (tracer._tracer instanceof NoopTracer) {
2434
// We still need to register these tasks or the support file will fail

0 commit comments

Comments
 (0)