Skip to content

feature request: new rule; no-render-in-setup #207

Closed
@benmonro

Description

@benmonro

imo, it would be nice to have a rule that doesn't allow the usage of render in setup functions (before, beforeEach, etc)

Would also be nice to have the ability to configure custom render functions, we have one for renderWithContext for example.

I've seen people do code like this:

beforeEach(() => {
  render(<MyComponent />);
});

it("Should have foo", () => {
  expect(screen.getByText("foo")).toBeInTheDocument();
});

it("Should have bar", () => {
  expect(screen.getByText("bar")).toBeInTheDocument();
});

it("Should have baz", () => {
  expect(screen.getByText("baz")).toBeInTheDocument();
});

imo this should just be a single test. why render it N times when nothing is changing in the render?

Metadata

Metadata

Assignees

Labels

new ruleNew rule to be included in the pluginreleased

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions