@newrelic/test-utilities
Advanced tools
Comparing version 7.1.1 to 7.2.0
@@ -28,2 +28,3 @@ /* | ||
addAssert('transaction', 1, _tapper1(_transactionTest)) | ||
addAssert('clmAttrs', 1, _tapper1(_assertCLMAttrs)) | ||
@@ -370,3 +371,3 @@ addAssert('metrics', 1, _tapper1(_metricsTest)) | ||
function _asserter1(test) { | ||
return function asertionTest(x, message) { | ||
return function assertionTest(x, message) { | ||
const res = test(x) | ||
@@ -380,3 +381,3 @@ if (!res.success) { | ||
function _asserter2(test) { | ||
return function asertionTest(x, y, message) { | ||
return function assertionTest(x, y, message) { | ||
const res = test(x, y) | ||
@@ -408,1 +409,43 @@ if (!res.success) { | ||
} | ||
/** | ||
* Asserts the appropriate Code Level Metrics attributes on a segment | ||
* | ||
* @param {object} params | ||
* @param {object} params.segments list of segments to assert { segment, filepath, name } | ||
* @param {boolean} params.enabled if CLM is enabled or not | ||
* @param {object} params.test tap test context, to allow the use of tap assertions here | ||
*/ | ||
function _assertCLMAttrs({ segments, enabled: clmEnabled, test }) { | ||
segments.forEach((segment) => { | ||
const attrs = segment.segment.getAttributes() | ||
if (clmEnabled) { | ||
test.ok(attrs['code.function'], 'should have code.function') | ||
test.equal( | ||
attrs['code.function'], | ||
segment.name, | ||
'code.function value should match segment.name' | ||
) | ||
test.ok( | ||
attrs['code.filepath'].endsWith(segment.filepath), | ||
`code.filepath (${attrs['code.filepath']}) should end with ${segment.filepath}` | ||
) | ||
test.match(attrs['code.lineno'], /[\d]+/, 'lineno should be a number') | ||
test.match(attrs['code.column'], /[\d]+/, 'column should be a number') | ||
return { | ||
success: true, | ||
message: `CLM behaves as expected when active` | ||
} | ||
} | ||
test.notOk(attrs['code.function'], 'code.function should not exist') | ||
test.notOk(attrs['code.filepath'], 'code.filepath should not exist') | ||
test.notOk(attrs['code.lineno'], 'code.lineno should not exist') | ||
test.notOk(attrs['code.column'], 'code.column should not exist') | ||
return { | ||
success: true, | ||
message: `CLM should noop when inactive` | ||
} | ||
}) | ||
return { success: true, message: 'CLM behaves as expected' } | ||
} | ||
assert.clmAttrs = _asserter1(_assertCLMAttrs) |
@@ -9,3 +9,6 @@ /* | ||
const semver = require('semver') | ||
const urltils = require(getNewRelicLocation() + '/lib/util/urltils') | ||
const newRelicLoc = getNewRelicLocation() | ||
const urltils = require(newRelicLoc + '/lib/util/urltils') | ||
const clmUtils = require(newRelicLoc + '/lib/util/code-level-metrics') | ||
const symbols = require(newRelicLoc + '/lib/symbols') | ||
@@ -188,1 +191,4 @@ /** | ||
} | ||
util.symbols = symbols | ||
util.clmUtils = clmUtils |
{ | ||
"name": "@newrelic/test-utilities", | ||
"version": "7.1.1", | ||
"version": "7.2.0", | ||
"description": "Test library for New Relic instrumentation modules.", | ||
@@ -13,3 +13,3 @@ "main": "index.js", | ||
"third-party-updates": "oss third-party manifest && oss third-party notices && git add THIRD_PARTY_NOTICES.md third_party_manifest.json", | ||
"unit": "tap tests/unit/*.tap.js tests/unit/*/*.tap.js --no-coverage --reporter classic", | ||
"unit": "c8 -o ./coverage/unit tap tests/unit/*.tap.js tests/unit/*/*.tap.js --no-coverage --reporter classic", | ||
"prepare": "husky install" | ||
@@ -37,2 +37,3 @@ }, | ||
"@newrelic/newrelic-oss-cli": "^0.1.2", | ||
"c8": "^7.12.0", | ||
"eslint": "^7.32.0", | ||
@@ -46,3 +47,3 @@ "eslint-config-prettier": "^8.3.0", | ||
"lint-staged": "^11.0.0", | ||
"newrelic": "^8.6.0", | ||
"newrelic": "^9.7.2", | ||
"prettier": "^2.3.2", | ||
@@ -57,3 +58,3 @@ "sinon": "^11.1.1", | ||
"concat-stream": "^1.6.0", | ||
"glob": "^7.2.0", | ||
"glob": "^7.2.3", | ||
"lodash": "^4.17.5", | ||
@@ -60,0 +61,0 @@ "log-update": "^1.0.2", |
@@ -1,5 +0,7 @@ | ||
[![Community Project header](https://github.com/newrelic/opensource-website/raw/master/src/images/categories/Community_Project.png)](https://opensource.newrelic.com/oss-category/#community-project) | ||
[![Community Project header](https://github.com/newrelic/opensource-website/raw/main/src/images/categories/Community_Project.png)](https://opensource.newrelic.com/oss-category/#community-project) | ||
# New Relic Test Utilities [![Test Utilities CI][1]][2] | ||
# New Relic Test Utilities | ||
[![npm status badge][3]][4] [![Test Utilities CI][1]][2] [![codecov][5]][6] | ||
Library full of test utilities and helpers for New Relic instrumentation modules. | ||
@@ -243,1 +245,5 @@ The full documentation for this module can be | ||
[2]: https://github.com/newrelic/node-test-utilities/actions?query=workflow%3A%22Test+Utilities+CI%22 | ||
[3]: https://img.shields.io/npm/v/@newrelic/test-utilities.svg | ||
[4]: https://www.npmjs.com/package/@newrelic/test-utilities | ||
[5]: https://codecov.io/gh/newrelic/node-test-utilities/branch/main/graph/badge.svg | ||
[6]: https://codecov.io/gh/newrelic/node-test-utilities |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
92199
2119
248
15
22
Updatedglob@^7.2.3