Skip to content

Commit 0e9ea30

Browse files
authored
chore: activate more mocha lint rules (#6542)
This activates a few mocha lint rules that either do not report issues or that are easy fixable and that bring actual benefit such as preventing a duplicate title.
1 parent bb771aa commit 0e9ea30

File tree

34 files changed

+92
-28
lines changed

34 files changed

+92
-28
lines changed

eslint.config.mjs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -546,15 +546,10 @@ export default [
546546
rules: {
547547
'mocha/consistent-spacing-between-blocks': 'off',
548548
'mocha/max-top-level-suites': ['error', { limit: 1 }],
549-
'mocha/no-exports': 'off',
550-
'mocha/no-global-tests': 'off',
551-
'mocha/no-identical-title': 'off',
552549
'mocha/no-mocha-arrows': 'off',
553550
'mocha/no-setup-in-describe': 'off',
554551
'mocha/no-sibling-hooks': 'off',
555-
'mocha/no-skipped-tests': 'off',
556552
'mocha/no-top-level-hooks': 'off',
557-
'mocha/prefer-arrow-callback': 'off',
558553
'n/handle-callback-err': 'off',
559554
'n/no-missing-require': 'off',
560555
'require-await': 'off'

integration-tests/appsec/multer.spec.js

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

3-
const { assert } = require('chai')
4-
const path = require('path')
53
const axios = require('axios')
4+
const { assert } = require('chai')
5+
const { describe, it, beforeEach, afterEach, before, after } = require('mocha')
6+
7+
const path = require('node:path')
68

79
const {
810
createSandbox,
911
FakeAgent,
1012
spawnProc
1113
} = require('../helpers')
1214

13-
const { NODE_MAJOR } = require('../../version')
14-
15-
const describe = NODE_MAJOR <= 16 ? globalThis.describe.skip : globalThis.describe
16-
1715
describe('multer', () => {
1816
let sandbox, cwd, startupTestFile, agent, proc, env
1917

integration-tests/ci-visibility/dynamic-instrumentation/test-hit-breakpoint.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const sum = require('./dependency')
44
const { expect } = require('chai')
55

66
let count = 0
7+
78
describe('dynamic-instrumentation', () => {
89
it('retries with DI', function () {
910
if (process.env.TEST_SHOULD_PASS_AFTER_RETRY && count++ === 1) {

integration-tests/ci-visibility/dynamic-instrumentation/test-not-hit-breakpoint.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const sum = require('./dependency')
44
const { expect } = require('chai')
55

66
let count = 0
7+
78
describe('dynamic-instrumentation', () => {
89
it('retries with DI', function () {
910
const willFail = count++ === 0

integration-tests/ci-visibility/test-early-flake-detection/skipped-and-todo-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ describe('ci visibility', () => {
1010
if (typeof jest !== 'undefined') {
1111
it.todo('todo will not be retried')
1212
}
13+
1314
it.skip('skip will not be retried', () => {
1415
expect(1 + 2).to.equal(4)
1516
})

integration-tests/cucumber/cucumber.spec.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ versions.forEach(version => {
112112
reportMethods.forEach((reportMethod) => {
113113
context(`reporting via ${reportMethod}`, () => {
114114
let envVars, isAgentless, logsEndpoint
115+
115116
beforeEach(() => {
116117
isAgentless = reportMethod === 'agentless'
117118
envVars = isAgentless ? getCiVisAgentlessConfig(receiver.port) : getCiVisEvpProxyConfig(receiver.port)
@@ -269,6 +270,7 @@ versions.forEach(version => {
269270
})
270271
})
271272
})
273+
272274
context('intelligent test runner', () => {
273275
it('can report git metadata', (done) => {
274276
const searchCommitsRequestPromise = receiver.payloadReceived(
@@ -1240,7 +1242,8 @@ versions.forEach(version => {
12401242
})
12411243
})
12421244

1243-
if (version !== '7.0.0') { // EFD in parallel mode only supported from cucumber>=11
1245+
if (version !== '7.0.0') {
1246+
// EFD in parallel mode only supported from cucumber>=11
12441247
context('parallel mode', () => {
12451248
it('retries new tests', (done) => {
12461249
const NUM_RETRIES_EFD = 3
@@ -1530,7 +1533,8 @@ versions.forEach(version => {
15301533
}
15311534
})
15321535

1533-
if (version === 'latest') { // flaky test retries only supported from >=8.0.0
1536+
if (version === 'latest') {
1537+
// flaky test retries only supported from >=8.0.0
15341538
context('flaky test retries', () => {
15351539
it('can retry failed tests', (done) => {
15361540
receiver.setSettings({

integration-tests/helpers/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ function useEnv (env) {
463463
before(() => {
464464
Object.assign(process.env, env)
465465
})
466+
466467
after(() => {
467468
for (const key of Object.keys(env)) {
468469
delete process.env[key]
@@ -474,6 +475,7 @@ function useSandbox (...args) {
474475
before(async () => {
475476
sandbox = await createSandbox(...args)
476477
})
478+
477479
after(() => {
478480
const oldSandbox = sandbox
479481
sandbox = undefined
@@ -489,6 +491,7 @@ function setShouldKill (value) {
489491
before(() => {
490492
shouldKill = value
491493
})
494+
492495
after(() => {
493496
shouldKill = true
494497
})

integration-tests/init.spec.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ delete process.env.DD_INJECT_FORCE
3131
function testInjectionScenarios (arg, filename, esmWorks = false) {
3232
if (!currentVersionIsSupported) return
3333
const doTest = (file, ...args) => testFile(file, ...args)
34+
3435
context('preferring app-dir dd-trace', () => {
3536
context('when dd-trace is not in the app dir', () => {
3637
const NODE_OPTIONS = `--no-warnings --${arg} ${path.join(__dirname, '..', filename)}`
@@ -39,34 +40,45 @@ function testInjectionScenarios (arg, filename, esmWorks = false) {
3940
if (currentVersionIsSupported) {
4041
context('without DD_INJECTION_ENABLED', () => {
4142
it('should initialize the tracer', () => doTest('init/trace.js', 'true\n', [], 'manual'))
43+
4244
it('should initialize instrumentation', () => doTest('init/instrument.js', 'true\n', [], 'manual'))
45+
4346
it(`should ${esmWorks ? '' : 'not '}initialize ESM instrumentation`, () =>
4447
doTest('init/instrument.mjs', `${esmWorks}\n`, [], 'manual'))
4548
})
4649
}
50+
4751
context('with DD_INJECTION_ENABLED', () => {
4852
useEnv({ DD_INJECTION_ENABLED })
4953

5054
it('should not initialize the tracer', () => doTest('init/trace.js', 'false\n', []))
55+
5156
it('should not initialize instrumentation', () => doTest('init/instrument.js', 'false\n', []))
57+
5258
it('should not initialize ESM instrumentation', () => doTest('init/instrument.mjs', 'false\n', []))
5359
})
5460
})
61+
5562
context('when dd-trace in the app dir', () => {
5663
const NODE_OPTIONS = `--no-warnings --${arg} dd-trace/${filename}`
5764
useEnv({ NODE_OPTIONS })
5865

5966
context('without DD_INJECTION_ENABLED', () => {
6067
it('should initialize the tracer', () => doTest('init/trace.js', 'true\n', [], 'manual'))
68+
6169
it('should initialize instrumentation', () => doTest('init/instrument.js', 'true\n', [], 'manual'))
70+
6271
it(`should ${esmWorks ? '' : 'not '}initialize ESM instrumentation`, () =>
6372
doTest('init/instrument.mjs', `${esmWorks}\n`, [], 'manual'))
6473
})
74+
6575
context('with DD_INJECTION_ENABLED', () => {
6676
useEnv({ DD_INJECTION_ENABLED, DD_TRACE_DEBUG })
6777

6878
it('should initialize the tracer', () => doTest('init/trace.js', 'true\n', telemetryGood, 'ssi'))
79+
6980
it('should initialize instrumentation', () => doTest('init/instrument.js', 'true\n', telemetryGood, 'ssi'))
81+
7082
it(`should ${esmWorks ? '' : 'not '}initialize ESM instrumentation`, () =>
7183
doTest('init/instrument.mjs', `${esmWorks}\n`, telemetryGood, 'ssi'))
7284
})
@@ -91,15 +103,17 @@ function testRuntimeVersionChecks (arg, filename) {
91103
context('when node version is less than engines field', () => {
92104
useEnv({ NODE_OPTIONS })
93105

94-
it('should not initialize the tracer', () =>
95-
doTest('false\n', []))
106+
it('should not initialize the tracer', () => doTest('false\n', []))
107+
96108
context('with DD_INJECTION_ENABLED', () => {
97109
useEnv({ DD_INJECTION_ENABLED })
98110

99111
context('without debug', () => {
100112
it('should not initialize the tracer', () => doTest('false\n', telemetryAbort))
113+
101114
it('should initialize the tracer, if DD_INJECT_FORCE', () => doTestForced('true\n', telemetryForced))
102115
})
116+
103117
context('with debug', () => {
104118
useEnv({ DD_TRACE_DEBUG })
105119

@@ -109,6 +123,7 @@ Found incompatible runtime Node.js ${process.versions.node}, Supported runtimes:
109123
>=18.
110124
false
111125
`, telemetryAbort))
126+
112127
it('should initialize the tracer, if DD_INJECT_FORCE', () =>
113128
doTestForced(`Aborting application instrumentation due to incompatible_runtime.
114129
Found incompatible runtime Node.js ${process.versions.node}, Supported runtimes: Node.js \
@@ -125,19 +140,23 @@ true
125140
useEnv({ NODE_OPTIONS })
126141

127142
it('should initialize the tracer, if no DD_INJECTION_ENABLED', () => doTest('true\n', [], 'manual'))
143+
128144
context('with DD_INJECTION_ENABLED', () => {
129145
useEnv({ DD_INJECTION_ENABLED })
130146

131147
context('without debug', () => {
132148
it('should initialize the tracer', () => doTest('true\n', telemetryGood, 'ssi'))
149+
133150
it('should initialize the tracer, if DD_INJECT_FORCE', () =>
134151
doTestForced('true\n', telemetryGood, 'ssi'))
135152
})
153+
136154
context('with debug', () => {
137155
useEnv({ DD_TRACE_DEBUG })
138156

139157
it('should initialize the tracer', () =>
140158
doTest('Application instrumentation bootstrapping complete\ntrue\n', telemetryGood, 'ssi'))
159+
141160
it('should initialize the tracer, if DD_INJECT_FORCE', () =>
142161
doTestForced('Application instrumentation bootstrapping complete\ntrue\n', telemetryGood, 'ssi'))
143162
})
@@ -183,6 +202,7 @@ if (semver.satisfies(process.versions.node, '>=14.13.1')) {
183202
process.versions.node !== '18.0.0')
184203
testRuntimeVersionChecks('loader', 'initialize.mjs')
185204
})
205+
186206
if (semver.satisfies(process.versions.node, '>=20.6.0')) {
187207
context('as --import', () => {
188208
testInjectionScenarios('import', 'initialize.mjs', true)

integration-tests/jest/jest.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,7 @@ describe('jest CommonJS', () => {
950950
})
951951
})
952952
})
953+
953954
it('can report code coverage', (done) => {
954955
const libraryConfigRequestPromise = receiver.payloadReceived(
955956
({ url }) => url === '/api/v2/libraries/tests/services/setting'

integration-tests/mocha/mocha.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,7 @@ describe('mocha CommonJS', function () {
644644
})
645645
})
646646
})
647+
647648
it('can report code coverage', (done) => {
648649
let testOutput
649650
const libraryConfigRequestPromise = receiver.payloadReceived(
@@ -3504,6 +3505,7 @@ describe('mocha CommonJS', function () {
35043505
}
35053506
)
35063507
})
3508+
35073509
context('test is new', () => {
35083510
it('should be retried and marked both as new and modified', (done) => {
35093511
receiver.setKnownTests({

0 commit comments

Comments
 (0)