Skip to content

Vertical version is not working in unit tests. #108

@huseyindeniz

Description

@huseyindeniz

Hi and thanks for this beautiful package. I'm having trouble with unit testing of my component which uses vertical steps. Here is a simple demonstration:

import { Box, ChakraProvider } from "@chakra-ui/react";
import { render } from "@testing-library/react";
import { Steps, Step } from "chakra-ui-steps";

import { theme } from "../../../../ui/components/Layout/Theme/theme";

import { Modal } from "./Modal";

describe("Feature: Wallet", () => {
  describe("Component: ConnectionModal/Modal", () => {
    const onClickSpy = jest.fn();

    describe("Scenario: CheckWallet", () => {
      it("should show correct step", () => {
        // Arrange
        // Act
        const { debug } = render(
          <Box>
            <Steps colorScheme="green" activeStep={0} orientation="vertical">
              <Step label="Step 1" />
              <Step label="Step 2" />
              <Step label="Step 3" />
            </Steps>
          </Box>
        );
        // Assert
      });
    });
  });
});

This test fails with the famous error: TypeError: Cannot read properties of undefined (reading 'width')

But if I only remove orientation="vertical" or make it orientation="horizontal", it works fine. Steps is correctly defined in my theme configuration on both application and test-utils file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions