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

add documentation regarding raven-teskit plugin #1231

Merged
merged 4 commits into from
Mar 19, 2018
Merged
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
46 changes: 46 additions & 0 deletions docs/tips.rst
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,49 @@ and will fail on slow connection or long response time:
dataType: 'script',
crossDomain: true
});


Raven Test Kit
--------------
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 <https://github.com/wix/raven-testkit>`_ 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.

Installation
````````````
.. code-block:: sh

$ npm install raven-testkit --save-dev

How to Use
``````````
Then you may create a ``testkit`` instance and validate your reports against it as follows:

.. code:: javascript

import testKitInitializer from 'raven-testkit'

const testKit = testKitInitializer(Raven)

// any scenario that should call Raven.catchException(...)

expect(testKit.reports()).to.have.lengthOf(1)
const report = testKit.reports()[0]
expect(report).to.have.property('release').to.equal('test')


Additionally, you may pass your own ``shouldSendCallback`` logic

.. code:: javascript

const shouldSendCallback = data => {
return /* your own logic */
}
const testKit = testKitInitializer(Raven, shouldSendCallback)


Other useful API, more example usage and updates can be found in `Raven Test Kit <https://github.com/wix/raven-testkit>`_