Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DI] Switch unit tests to Mocha instead of Tap #4728

Merged
merged 3 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"test:appsec:ci": "nyc --no-clean --include \"packages/dd-trace/src/appsec/**/*.js\" --exclude \"packages/dd-trace/test/appsec/**/*.plugin.spec.js\" -- npm run test:appsec",
"test:appsec:plugins": "mocha -r \"packages/dd-trace/test/setup/mocha.js\" \"packages/dd-trace/test/appsec/**/*.@($(echo $PLUGINS)).plugin.spec.js\"",
"test:appsec:plugins:ci": "yarn services && nyc --no-clean --include \"packages/dd-trace/src/appsec/**/*.js\" -- npm run test:appsec:plugins",
"test:debugger": "tap packages/dd-trace/test/debugger/**/*.spec.js",
"test:debugger:ci": "npm run test:debugger -- --coverage --nyc-arg=--include=\"packages/dd-trace/src/debugger/**/*.js\"",
"test:debugger": "mocha -r 'packages/dd-trace/test/setup/mocha.js' 'packages/dd-trace/test/debugger/**/*.spec.js'",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(absolute nit) unrelated to this PR: using :debugger is a bit confusing to me given that debugger is a keyword and that I usually use test:debug to pass --inspect-brk to test sessions.

Maybe test:dynamic-inst ? That's awful 😆 , so feel free to disregard

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have preferred to use something related to our product name as well, but it's called "debugger" in all the other languages for historical reasons, so I was told to use this name in Node.js as well. I'll ask around to see if we still think this is a good idea. But if we decide to rename it, I'll make a separate PR as it touches a lot of other areas of the code as well - not just these lines.

"test:debugger:ci": "nyc --no-clean --include 'packages/dd-trace/src/debugger/**/*.js' -- npm run test:debugger",
"test:trace:core": "tap packages/dd-trace/test/*.spec.js \"packages/dd-trace/test/{ci-visibility,datastreams,encode,exporters,opentelemetry,opentracing,plugins,service-naming,telemetry}/**/*.spec.js\"",
"test:trace:core:ci": "npm run test:trace:core -- --coverage --nyc-arg=--include=\"packages/dd-trace/src/**/*.js\"",
"test:instrumentations": "mocha -r 'packages/dd-trace/test/setup/mocha.js' 'packages/datadog-instrumentations/test/**/*.spec.js'",
Expand Down
16 changes: 8 additions & 8 deletions packages/dd-trace/test/debugger/devtools_client/status.spec.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict'

require('../../setup/tap')
require('../../setup/mocha')

const ddsource = 'dd_debugger'
const service = 'my-service'
const runtimeId = 'my-runtime-id'

describe('diagnostic message http request caching', () => {
describe('diagnostic message http request caching', function () {
let statusproxy, request

const acks = [
Expand All @@ -16,7 +16,7 @@ describe('diagnostic message http request caching', () => {
['ackError', 'ERROR', new Error('boom')]
]

beforeEach(() => {
beforeEach(function () {
request = sinon.spy()
request['@noCallThru'] = true

Expand All @@ -27,10 +27,10 @@ describe('diagnostic message http request caching', () => {
})

for (const [ackFnName, status, err] of acks) {
describe(ackFnName, () => {
describe(ackFnName, function () {
let ackFn, exception

beforeEach(() => {
beforeEach(function () {
if (err) {
ackFn = statusproxy[ackFnName].bind(null, err)
// Use `JSON.stringify` to remove any fields that are `undefined`
Expand All @@ -45,7 +45,7 @@ describe('diagnostic message http request caching', () => {
}
})

it('should only call once if no change', () => {
it('should only call once if no change', function () {
ackFn({ id: 'foo', version: 0 })
expect(request).to.have.been.calledOnce
assertRequestData(request, { probeId: 'foo', version: 0, status, exception })
Expand All @@ -54,7 +54,7 @@ describe('diagnostic message http request caching', () => {
expect(request).to.have.been.calledOnce
})

it('should call again if version changes', () => {
it('should call again if version changes', function () {
ackFn({ id: 'foo', version: 0 })
expect(request).to.have.been.calledOnce
assertRequestData(request, { probeId: 'foo', version: 0, status, exception })
Expand All @@ -64,7 +64,7 @@ describe('diagnostic message http request caching', () => {
assertRequestData(request, { probeId: 'foo', version: 1, status, exception })
})

it('should call again if probeId changes', () => {
it('should call again if probeId changes', function () {
ackFn({ id: 'foo', version: 0 })
expect(request).to.have.been.calledOnce
assertRequestData(request, { probeId: 'foo', version: 0, status, exception })
Expand Down
Loading