Skip to content

Commit aa76e2a

Browse files
authored
[DI] Clean up code in integration test (#5729)
It's best practice to not call `it` dynamically in a for-loop, but instead have a function that returns a test function so that the `it` statements can be hard coded even when you need to re-use a test function.
1 parent 57da289 commit aa76e2a

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

integration-tests/debugger/basic.spec.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -174,20 +174,25 @@ describe('Dynamic Instrumentation', function () {
174174
}
175175
})
176176

177-
const unsupporedOrInvalidProbes = [[
177+
it(
178178
'should send expected error diagnostics messages if probe doesn\'t conform to expected schema',
179-
'bad config!!!',
180-
{ status: 'ERROR' }
181-
], [
179+
unsupporedOrInvalidProbesTest('bad config!!!', { status: 'ERROR' })
180+
)
181+
182+
it(
182183
'should send expected error diagnostics messages if probe type isn\'t supported',
183-
t.generateProbeConfig({ type: 'INVALID_PROBE' })
184-
], [
184+
unsupporedOrInvalidProbesTest(t.generateProbeConfig({ type: 'INVALID_PROBE' }))
185+
)
186+
187+
it(
185188
'should send expected error diagnostics messages if it isn\'t a line-probe',
186-
t.generateProbeConfig({ where: { foo: 'bar' } }) // TODO: Use valid schema for method probe instead
187-
]]
189+
unsupporedOrInvalidProbesTest(
190+
t.generateProbeConfig({ where: { typeName: 'index.js', methodName: 'handlerA' } })
191+
)
192+
)
188193

189-
for (const [title, config, customErrorDiagnosticsObj] of unsupporedOrInvalidProbes) {
190-
it(title, function (done) {
194+
function unsupporedOrInvalidProbesTest (config, customErrorDiagnosticsObj) {
195+
return function (done) {
191196
let receivedAckUpdate = false
192197

193198
t.agent.on('remote-config-ack-update', (id, version, state, error) => {
@@ -238,7 +243,7 @@ describe('Dynamic Instrumentation', function () {
238243
function endIfDone () {
239244
if (receivedAckUpdate && expectedPayloads.length === 0) done()
240245
}
241-
})
246+
}
242247
}
243248

244249
describe('multiple probes at the same location', function () {

0 commit comments

Comments
 (0)