Skip to content

Commit dac1ec5

Browse files
authored
test: completely remove chai and fix type errors (#7144)
* test: fix env type errors Environment variables may only be of type string or undefined. * test: remove all chai related code Instead, the code is now using Node.js assert or a native testing library available by a test runner. * test: fix opentracing tests This uses a hack to keep them supported, since they use chai. To do so, a fake chai is introduced when loading that test file. * test: remove unused deepInclude test helper It was not used for a while and could be replaced with the more generic partial deep strict equal helper.
1 parent 4b40f00 commit dac1ec5

30 files changed

Lines changed: 155 additions & 195 deletions

benchmark/sirun/startup/startup-test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ if (Number(process.env.EVERYTHING)) {
2727
'axios',
2828
'benchmark',
2929
'body-parser',
30-
'chai',
3130
'crypto-randomuuid',
3231
'dc-polyfill',
3332
'eslint-plugin-cypress',
@@ -67,7 +66,6 @@ if (Number(process.env.EVERYTHING)) {
6766
'semifies',
6867
'semver',
6968
'shell-quote',
70-
'sinon-chai',
7169
'sinon',
7270
'source-map',
7371
'tap',

eslint.config.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,6 @@ export default [
595595
allowModules: [
596596
...Object.keys(dependencies),
597597
'mocha',
598-
'chai'
599598
]
600599
}],
601600
'n/no-missing-require': 'off',

integration-tests/appsec/data-collection.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('ASM Data collection', () => {
2727

2828
const env = {
2929
DD_TRACE_AGENT_PORT: agent.port,
30-
DD_APPSEC_ENABLED: true,
30+
DD_APPSEC_ENABLED: 'true',
3131
DD_APPSEC_RULES: path.join(cwd, 'appsec', 'data-collection', 'data-collection-rules.json')
3232
}
3333

integration-tests/appsec/response-headers.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('Headers collection - Fastify', () => {
2626

2727
const env = {
2828
DD_TRACE_AGENT_PORT: agent.port,
29-
DD_APPSEC_ENABLED: true,
29+
DD_APPSEC_ENABLED: 'true',
3030
DD_APPSEC_RULES: path.join(cwd, 'appsec/data-collection/data-collection-rules.json')
3131
}
3232
proc = await spawnProc(appFile, { cwd, env, execArgv: [] })

integration-tests/appsec/trace-tagging.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('ASM Trace Tagging rules', () => {
2020

2121
const env = {
2222
DD_TRACE_AGENT_PORT: agent.port,
23-
DD_APPSEC_ENABLED: true,
23+
DD_APPSEC_ENABLED: 'true',
2424
DD_APPSEC_RULES: path.join(cwd, 'appsec', 'data-collection', 'data-collection-rules.json')
2525
}
2626

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ describe('test optimization automatic log submission', () => {
2424
'@cucumber/cucumber',
2525
'jest',
2626
'winston',
27-
'chai@4',
2827
'@playwright/test'
2928
], true)
3029

@@ -73,7 +72,7 @@ describe('test optimization automatic log submission', () => {
7372
getExtraEnvVars: () => ({
7473
PW_BASE_URL: `http://localhost:${webAppPort}`,
7574
TEST_DIR: 'ci-visibility/automatic-log-submission-playwright',
76-
DD_TRACE_DEBUG: 1
75+
DD_TRACE_DEBUG: '1'
7776
})
7877
}
7978
]

integration-tests/cucumber/cucumber.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1838,7 +1838,7 @@ describe(`cucumber@${version} commonJS`, () => {
18381838
cwd,
18391839
env: {
18401840
...envVars,
1841-
DD_CIVISIBILITY_FLAKY_RETRY_COUNT: 1
1841+
DD_CIVISIBILITY_FLAKY_RETRY_COUNT: '1'
18421842
},
18431843
stdio: 'pipe'
18441844
}

integration-tests/cypress/cypress.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2012,7 +2012,7 @@ moduleTypes.forEach(({
20122012
env: {
20132013
...restEnvVars,
20142014
CYPRESS_BASE_URL: `http://localhost:${webAppPort}`,
2015-
DD_CIVISIBILITY_FLAKY_RETRY_COUNT: 1,
2015+
DD_CIVISIBILITY_FLAKY_RETRY_COUNT: '1',
20162016
SPEC_PATTERN: specToRun
20172017
},
20182018
stdio: 'pipe'
@@ -2302,7 +2302,7 @@ moduleTypes.forEach(({
23022302
CYPRESS_BASE_URL: `http://localhost:${webAppPort}`,
23032303
CYPRESS_BASE_URL_SECOND: `http://localhost:${secondWebAppPort}`,
23042304
SPEC_PATTERN: specToRun,
2305-
DD_TRACE_DEBUG: true
2305+
DD_TRACE_DEBUG: 'true'
23062306
},
23072307
stdio: 'pipe'
23082308
}

integration-tests/debugger/basic.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ describe('Dynamic Instrumentation', function () {
767767

768768
describe('DD_TRACING_ENABLED=true, DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED=true', function () {
769769
const t = setup({
770-
env: { DD_TRACING_ENABLED: true, DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED: true },
770+
env: { DD_TRACING_ENABLED: 'true', DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED: true },
771771
dependencies: ['fastify']
772772
})
773773

@@ -778,7 +778,7 @@ describe('Dynamic Instrumentation', function () {
778778

779779
describe('DD_TRACING_ENABLED=true, DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED=false', function () {
780780
const t = setup({
781-
env: { DD_TRACING_ENABLED: true, DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED: false },
781+
env: { DD_TRACING_ENABLED: 'true', DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED: false },
782782
dependencies: ['fastify']
783783
})
784784

@@ -789,7 +789,7 @@ describe('Dynamic Instrumentation', function () {
789789

790790
describe('DD_TRACING_ENABLED=false', function () {
791791
const t = setup({
792-
env: { DD_TRACING_ENABLED: false },
792+
env: { DD_TRACING_ENABLED: 'false' },
793793
dependencies: ['fastify']
794794
})
795795

integration-tests/jest/jest.spec.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ describe(`jest@${JEST_VERSION} commonJS`, () => {
101101

102102
useSandbox([
103103
`jest@${JEST_VERSION}`,
104-
'chai@v4',
105104
`jest-jasmine2@${JEST_VERSION}`,
106105
// jest-environment-jsdom is included in older versions of jest
107106
JEST_VERSION === 'latest' && `jest-environment-jsdom@${JEST_VERSION}`,
@@ -2792,7 +2791,7 @@ describe(`jest@${JEST_VERSION} commonJS`, () => {
27922791
...getCiVisAgentlessConfig(receiver.port), // use agentless for this test, just for variety
27932792
TESTS_TO_RUN: 'test/ci-visibility-test',
27942793
ENABLE_JSDOM: true,
2795-
DD_TRACE_DEBUG: 1,
2794+
DD_TRACE_DEBUG: '1',
27962795
DD_TRACE_LOG_LEVEL: 'warn'
27972796
},
27982797
stdio: 'inherit'
@@ -3386,7 +3385,7 @@ describe(`jest@${JEST_VERSION} commonJS`, () => {
33863385
env: {
33873386
...getCiVisEvpProxyConfig(receiver.port),
33883387
TESTS_TO_RUN: 'jest-flaky/flaky-',
3389-
DD_CIVISIBILITY_FLAKY_RETRY_COUNT: 1
3388+
DD_CIVISIBILITY_FLAKY_RETRY_COUNT: '1'
33903389
},
33913390
stdio: 'inherit'
33923391
}
@@ -4801,7 +4800,7 @@ describe(`jest@${JEST_VERSION} commonJS`, () => {
48014800

48024801
fs.writeFileSync(
48034802
path.join(cwd, 'ci-visibility/test-impacted-test/test-impacted-1.js'),
4804-
`const { expect } = require('chai')
4803+
`const assert = require('assert')
48054804
48064805
describe('impacted tests', () => {
48074806
it('can pass normally', () => {

0 commit comments

Comments
 (0)