Get current state of context from SDK for testing #5120
Answered
by
vladanpaunovic
cameronmcefee
asked this question in
Q&A
-
Howdy 🤠 . Is it possible to get the current state of Sentry's context/tags/user so I can check it in my tests? I want to verify the actual stored data rather than spying on the various setters to check if they were called, since there are multiple ways things might get set. Thanks! |
Beta Was this translation helpful? Give feedback.
Answered by
vladanpaunovic
May 25, 2022
Replies: 1 comment 1 reply
-
Hey @cameronmcefee , of course. All you need to do is to access the current scope. Here is how to do that: import * as Sentry from "@sentry/browser" // or any other package you are using
const scope = Sentry.getCurrentHub().getScope();
console.log(scope) This will output something like this:
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
AbhiPrasad
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @cameronmcefee , of course. All you need to do is to access the current scope. Here is how to do that:
This will output something like this: