Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Fix race condition in test and reset mocks (#72150)

Romeo Van Snickfc07abb93ccb
diff --git a/frontend/src/metabase/dashboard/actions/cards.unit.spec.ts b/frontend/src/metabase/dashboard/actions/cards.unit.spec.ts
index 13480fa5653..ade1983e9c7 100644
--- a/frontend/src/metabase/dashboard/actions/cards.unit.spec.ts
+++ b/frontend/src/metabase/dashboard/actions/cards.unit.spec.ts
@@ -232,6 +232,10 @@ describe("dashboard/actions/cards", () => {
});
describe("replaceCard", () => {
+ beforeEach(() => {
+ jest.restoreAllMocks();
+ });
+
it("should correctly update the dashcard", async () => {
const { nextDashCard } = await runReplaceCardAction({
dashcardId: TABLE_DASHCARD.id,
@@ -333,12 +337,12 @@ async function runReplaceCardAction({
}: RunReplaceCardOpts) {
const { store } = setup(opts);
- await replaceCard({ dashcardId, nextCardId })(store.dispatch, store.getState);
- const nextState = store.getState();
-
const dispatchSpy = jest.spyOn(store, "dispatch");
const cardQueryEndpointSpy = jest.spyOn(CardApi, "query");
+ await replaceCard({ dashcardId, nextCardId })(store.dispatch, store.getState);
+ const nextState = store.getState();
+
return {
nextDashCard: getDashCardById(nextState, dashcardId),
dispatchSpy,