Skip to content

Commit

Permalink
chore: Updated express-esm, generic-pool, grpc, & grpc-esm tests to n…
Browse files Browse the repository at this point in the history
…ode:test
  • Loading branch information
jsumners-nr committed Nov 5, 2024
1 parent 9e98b18 commit 2cb3662
Show file tree
Hide file tree
Showing 34 changed files with 3,539 additions and 3,545 deletions.
2 changes: 1 addition & 1 deletion lib/instrumentation/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function wrapResponse(shim, response) {
if (!shim.isFunction(cb)) {
++cbIdx
cb = function defaultRenderCB(err, str) {
// https://github.com/expressjs/express/blob/4.x/lib/response.js#L961-L962
// https://github.com/expressjs/express/blob/4.x/lib/response.js#L961-L962
if (err) {
return res.req.next(err)
}
Expand Down
31 changes: 31 additions & 0 deletions test/lib/custom-assertions/not-has.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2024 New Relic Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/

'use strict'

const get = require('../../../lib/util/get')

/**
* Asserts that the `found` object does not contain a property as defined
* by `doNotWant`.
*
* @param {object} params Input parameters
* @param {object} found The object to test for absence.
* @param {string} doNotWant Dot separated path to a field that should not
* have a value.
* @param {string} [msg] Assertion message to include.
* @param {object} [deps] Injected dependencies.
* @param {object} [deps.assert] Assertion library to use.
*
* @throws {Error} When the `found` object contains a value at the specified
* `doNotWant` path.
*/
module.exports = function notHas(
{ found, doNotWant, msg },
{ assert = require('node:assert') } = {}
) {
const result = get(found, doNotWant)
assert.equal(result, undefined, msg)
}
21 changes: 4 additions & 17 deletions test/versioned/express-esm/helpers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ const helpers = Object.create(null)
* @returns { app, express }
*/
helpers.setup = async function setup() {
/**
* This rule is not fully fleshed out and the library is no longer maintained
* See: https://github.com/mysticatea/eslint-plugin-node/issues/250
* Fix would be to migrate to use https://github.com/weiran-zsd/eslint-plugin-node
*/

const { default: express } = await import('express')
const app = express()
return { app, express }
Expand All @@ -39,14 +33,13 @@ helpers.makeRequest = function makeRequest(server, endpoint) {
* Listens to express app, makes request, and returns transaction when `transactionFinished` event fires
*
* @param {Object} params
* @param {Object} params.app express instance
* @param {Object} params.t tap test
* @param {Object} params.server the underlying core server instance of the
* express app
* @param {Object} params.agent mocked agent
* @param {string} params.endpoint URI
*/
helpers.makeRequestAndFinishTransaction = async function makeRequestAndFinishTransaction({
app,
t,
server,
agent,
endpoint
}) {
Expand All @@ -59,13 +52,7 @@ helpers.makeRequestAndFinishTransaction = async function makeRequestAndFinishTra

agent.on('transactionFinished', transactionHandler)

const server = app.listen(function () {
helpers.makeRequest(this, endpoint)
})
t.teardown(() => {
server.close()
agent.removeListener('transactionFinished', transactionHandler)
})
helpers.makeRequest(server, endpoint)

return promise
}
Expand Down
7 changes: 3 additions & 4 deletions test/versioned/express-esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
}
},
"files": [
"segments.tap.mjs",
"transaction-naming.tap.mjs"
"segments.test.mjs",
"transaction-naming.test.mjs"
]
}
],
"dependencies": {}
]
}
Loading

0 comments on commit 2cb3662

Please sign in to comment.