Skip to content

Commit

Permalink
fix assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
jsumners-nr committed Dec 23, 2024
1 parent 5cc68f9 commit 6c63650
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 13 deletions.
4 changes: 2 additions & 2 deletions test/integration/instrumentation/fetch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ test('fetch', async function (t) {
}, 100)
await req
} catch (err) {
assert.ifError(err)
assert.match(err.message, /This operation was aborted/)
assertSegments(tx.trace.root, [`External/${HOST}/delay/1000`], { exact: false })
assert.equal(tx.exceptions.length, 1)
assert.equal(tx.exceptions[0].error.name, 'AbortError')
Expand All @@ -205,7 +205,7 @@ test('fetch', async function (t) {
try {
await req
} catch (error) {
assert.ifError(error)
assert.match(error.message, /fetch failed/)
assertSegments(transaction.trace.root, [`External/localhost:${port}/`], {
exact: false
})
Expand Down
2 changes: 1 addition & 1 deletion test/unit/collector/api-login.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ test('receiving no config back from connect', async (t) => {
await t.test('should pass along no server-side configuration from collector', (t, end) => {
const { collectorApi } = t.nr
collectorApi._login((error, res) => {
assert.ifError(error)
assert.equal(error.message, 'No agent run ID received from handshake.')
assert.equal(res.payload, undefined)
end()
})
Expand Down
2 changes: 1 addition & 1 deletion test/versioned/aws-sdk-v3/bedrock-chat-completions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ test('ai21: should properly create errors on create completion (streamed)', asyn
completion_id: /\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/
},
agentAttributes: {
spanId: /w+/
spanId: /\w+/
}
})

Expand Down
2 changes: 1 addition & 1 deletion test/versioned/express-esm/transaction-naming.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ test('names transaction when request is aborted', async (t) => {

const promise = new Promise((resolve) => {
app.use(function (error, req, res, next) {
plan.ifError(error)
plan.equal(error.message, 'some error')
plan.ok(agent.getTransaction() == null, 'no active transaction when responding')
res.end()
resolve()
Expand Down
6 changes: 5 additions & 1 deletion test/versioned/express/errors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
*/

'use strict'

// Make express quiet.
process.env.NODE_ENV = 'test'

const assert = require('node:assert')
const http = require('http')
const test = require('node:test')
Expand Down Expand Up @@ -199,7 +203,7 @@ test('Error handling tests', async (t) => {
})

app.use(function (error, req, res, next) {
plan.ifError(error)
plan.equal(error.message, 'some error')
plan.equal(agent.getTransaction(), null, 'no active transaction when responding')
res.end()
})
Expand Down
6 changes: 5 additions & 1 deletion test/versioned/express/transaction-naming.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
*/

'use strict'

// Make express quiet.
process.env.NODE_ENV = 'test'

const assert = require('node:assert')
const http = require('http')
const test = require('node:test')
Expand Down Expand Up @@ -345,7 +349,7 @@ test('names transaction when request is aborted', async function (t) {
})

app.use(function (error, req, res, next) {
plan.ifError(error)
plan.equal(error.message, 'some error')
plan.ok(agent.getTransaction() == null, 'no active transaction when responding')
res.end()
})
Expand Down
10 changes: 5 additions & 5 deletions test/versioned/restify/router.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ test('Restify router', async function (t) {

await t.test('introspection', async function (t) {
const { agent, server } = t.nr
const plan = tspl(t, { plan: 12 })
const plan = tspl(t, { plan: 13 })

// need to capture attributes
agent.config.attributes.enabled = true
Expand Down Expand Up @@ -79,7 +79,7 @@ test('Restify router', async function (t) {

await t.test('trailing slash differentiates routes (without slash)', async function (t) {
const { agent, server } = t.nr
const plan = tspl(t, { plan: 3 })
const plan = tspl(t, { plan: 4 })

server.get('/path1/', function first(req, res, next) {
plan.ok(0, 'should not enter this route')
Expand All @@ -98,7 +98,7 @@ test('Restify router', async function (t) {

await t.test('trailing slash differentiates routes (with slash)', async function (t) {
const { agent, server } = t.nr
const plan = tspl(t, { plan: 3 })
const plan = tspl(t, { plan: 4 })

server.get('/path1/', function first(req, res, next) {
plan.ok(agent.getTransaction(), 'should enter this route')
Expand All @@ -120,7 +120,7 @@ test('Restify router', async function (t) {
if (semver.satisfies(pkgVersion, '>=7.1.0')) {
await t.test('ignoreTrailingSlash option should ignore trailing slash', async function (t) {
const { agent } = t.nr
const plan = tspl(t, { plan: 3 })
const plan = tspl(t, { plan: 4 })

const server = require('restify').createServer({ ignoreTrailingSlash: true })

Expand All @@ -144,7 +144,7 @@ test('Restify router', async function (t) {
if (semver.satisfies(pkgVersion, '>=7.2.3')) {
await t.test('next(true): terminates processing', async function (t) {
const { agent, server } = t.nr
const plan = tspl(t, { plan: 4 })
const plan = tspl(t, { plan: 5 })

server.get(
'/test/:id',
Expand Down
2 changes: 1 addition & 1 deletion test/versioned/restify/rum.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const helper = require('../../lib/agent_helper')
const API = require('../../../api')

test('Restify router introspection', async function (t) {
const plan = tspl(t, { plan: 3 })
const plan = tspl(t, { plan: 4 })
const agent = helper.instrumentMockedAgent()
const server = require('restify').createServer()
const api = new API(agent)
Expand Down

0 comments on commit 6c63650

Please sign in to comment.