flexpect - v0.21.0
    Preparing search index...
    • Asserts that the target element is fully centered both horizontally and vertically within the specified container element.

      ┌─────────────────┐
      │                 │
      │   ┌─────────┐   │
      │   │ element │   │
      │   └─────────┘   │
      │                 │
      └─────────────────┘
      

      Parameters

      • element: Locator

        The element as a Locator to check for centering.

      • container: Locator

        The container element as a Locator relative to which centering is checked.

      • options: Tolerance = {}

        Optional centering options.

      Returns Promise<MatcherReturnType>

      A Promise that resolves with the matcher result.

      // Check that a modal is perfectly centered within the viewport, allowing a 2% margin
      const parentLocator = page.locator('#parent');
      await expect(modalLocator).toBeFullyCentered(parentLocator, {
      tolerance: 2,
      toleranceUnit: ToleranceUnit.Percent
      });