Skip to content

Commit

Permalink
Test actionTransformer and stateTransformer
Browse files Browse the repository at this point in the history
  • Loading branch information
onurtemizkan committed Oct 4, 2024
1 parent c8482b9 commit c7cfa72
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
10 changes: 9 additions & 1 deletion dev-packages/e2e-tests/test-applications/vue-3/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@ Sentry.init({
trackComponents: ['ComponentMainView', '<ComponentOneView>'],
});

pinia.use(Sentry.createSentryPiniaPlugin());
pinia.use(
Sentry.createSentryPiniaPlugin({
actionTransformer: action => `Transformed: ${action}`,
stateTransformer: state => ({
transformed: true,
...state,
}),
}),
);

app.use(pinia);
app.use(router);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ test('sends pinia action breadcrumbs and state context', async ({ page }) => {
const actionBreadcrumb = error.breadcrumbs?.find(breadcrumb => breadcrumb.category === 'action');

expect(actionBreadcrumb).toBeDefined();
expect(actionBreadcrumb?.message).toBe('addItem');
expect(actionBreadcrumb?.message).toBe('Transformed: addItem');
expect(actionBreadcrumb?.level).toBe('info');

const stateContext = error.contexts?.state?.state;

expect(stateContext).toBeDefined();
expect(stateContext?.type).toBe('pinia');
expect(stateContext?.value).toEqual({ rawItems: ['item'] });
expect(stateContext?.value).toEqual({
transformed: true,
rawItems: ['item'],
});
});

0 comments on commit c7cfa72

Please sign in to comment.