Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
raven-testkit
Advanced tools
Raven test kit module to enable reports to sentry in tests without really sending the report
Raven is a JavaScript SDK published by Sentry.io to enable software flow tracking and issues reporting to the Sentry system.
However, when building tests for your application, you want to assert that the right flow-tracking or error is being sent to Sentry, but without really sending it to the Sentry system. This way you won't swamp it with false reports during test running and other CI operations.
Raven test kit enables Raven to work natively in your application, but it overrides the default Raven transport mechanism so the report is not really sent but rather logged locally. In this way, the logged reports can be fetched later for usage verification or other uses you may have in your testing environment.
npm install raven-testkit --save-dev
// CommonJS
const testKitInitializer = require('raven-testkit')
// ES6 Modules
import testKitInitializer from 'raven-testkit'
const testKit = testKitInitializer(Raven)
// any scenario that should call Raven.catchException(...)
expect(testKit.reports()).toHaveLength(1)
const report = testKit.reports()[0]
expect(report).toHaveProperty('release', 'test')
shouldSendCallback
logicconst shouldSendCallback = data => {
return /* your own logic */
}
const testKit = testKitInitializer(Raven, shouldSendCallback)
You may see more example usage in the testing section of this repository as well.
Array
Get all existing reports.
Kind: instance function
Returns: Array
- where each member of the array consists of Raven
's data object.
See: You may refer to the Sentry Docs for further explanation and details.
Array
Reset the teskit state and clear all existing reports.
Object
Extract the exception object of a given report.
Returns: Object
- the exception object as built by Raven
Param | Type | Description |
---|---|---|
report | Object | report object. |
Object
Extract the exception object of a report in a specific position.
Returns: Object
- the exception object as built by Raven
Param | Type | Description |
---|---|---|
index | number | index position of the report |
Object
| undefined
Find a report by a given error.
Returns: Object
| undefined
- the report object if one found. undefined
otherwise
See: Uses Array.prototype.find
Param | Type | Description |
---|---|---|
error | Error | error to look for in the reports |
Boolean
check whether a given error exist (i.e. has been reported)
Returns: Boolean
- true
if the error exists. false
otherwise
Param | Type | Description |
---|---|---|
error | Error | the error to look for in the reports |
shouldSendCallback
hook in your Raven
configuration, make sure to call the testKitInitializer(Raven)
function after your code has finished configuring Raven. You need to do this because we call Raven.setShouldSendCallback
to ensure the proper functionality of the Raven
lifecycle so you need to call the testKitInitializer(Raven)
only after Raven
is configured.shouldSendCallback
logic to raven-testkit
.Raven.config(dummyDsn, { allowDuplicates: true })
(Documentation)FAQs
Raven test kit module to enable reports to sentry in tests without really sending the report
The npm package raven-testkit receives a total of 32 weekly downloads. As such, raven-testkit popularity was classified as not popular.
We found that raven-testkit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.