Skip to content

Conversation

maks-rafalko
Copy link
Owner

This rule disallows mixing expectations for different variables between each other.

The following patterns are considered errors:

// example 1
expect(foo).toBeDefined();
expect(bar).toBeNull();
expect(foo).toHaveLength(3); // should be placed before "bar"

// example 1
expect(foo).toBeDefined();
expect(bar).toBeNull();
expect(foo.bars).toHaveLength(3); // should be placed before "bar"

The following patterns are considered correct:

// example 1
expect(foo).toBeDefined();
expect(foo).toHaveLength(3);

expect(bar).toBeNull();

// example 2
expect(foo).toBeDefined();
expect(foo.bars).toHaveLength(3);

expect(bar).toBeNull();

This rule disallows mixing expectations for different variables between each other.

The following patterns are considered errors:

```ts
// example 1
expect(foo).toBeDefined();
expect(bar).toBeNull();
expect(foo).toHaveLength(3); // should be placed before "bar"

// example 1
expect(foo).toBeDefined();
expect(bar).toBeNull();
expect(foo.bars).toHaveLength(3); // should be placed before "bar"
```

The following patterns are considered correct:

```ts
// example 1
expect(foo).toBeDefined();
expect(foo).toHaveLength(3);

expect(bar).toBeNull();

// example 2
expect(foo).toBeDefined();
expect(foo.bars).toHaveLength(3);

expect(bar).toBeNull();
```
@maks-rafalko maks-rafalko merged commit 7648caa into main Jul 1, 2024
@maks-rafalko maks-rafalko deleted the feature/tests-groups branch July 1, 2024 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant