Skip to content

Commit

Permalink
test: try making less flakey tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mlaursen committed Nov 24, 2024
1 parent 9b3b95e commit 7d5fc07
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"clean": "TURBO_TELEMETRY_DISABLED=1 turbo run clean && pnpm clean-root",
"clean-dist": "TURBO_TELEMETRY_DISABLED=1 turbo run clean-dist",
"clean-root": "rm -rf .turbo coverage node_modules",
"test": "TURBO_TELEMETRY_DISABLED=1 turbo run test --concurrency=1",
"test": "TURBO_TELEMETRY_DISABLED=1 turbo run test",
"typecheck": "TURBO_TELEMETRY_DISABLED=1 turbo run typecheck",
"validate": "pnpm run lint && pnpm run typecheck",
"format": "prettier --write .",
Expand Down
12 changes: 11 additions & 1 deletion packages/core/src/navigation/__tests__/NavItemButton.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { describe, expect, it, jest } from "@jest/globals";
import { createRef, type ReactElement, type Ref } from "react";
import { type IconRotatorBaseProps } from "../../icon/IconRotator.js";
import { rmdRender, screen, userEvent } from "../../test-utils/index.js";
import {
rmdRender,
screen,
userEvent,
waitFor,
} from "../../test-utils/index.js";
import { useToggle } from "../../useToggle.js";
import { NavItemButton, type NavItemButtonProps } from "../NavItemButton.js";

Expand Down Expand Up @@ -100,6 +105,11 @@ describe("NavItemButton", () => {
const tooltip = await screen.findByRole("tooltip", {
name: "Content",
});
// Make the test less flakey by waiting for the fixed positioning style
// to have been calculated at least once with the tooltip element
await waitFor(() => {
expect(tooltip).toHaveStyle("left: 24px");
});

expect(tooltip).toMatchSnapshot();
});
Expand Down

0 comments on commit 7d5fc07

Please sign in to comment.