Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add skip and only for tests #5906

Merged
merged 11 commits into from Apr 30, 2024
Merged

Add skip and only for tests #5906

merged 11 commits into from Apr 30, 2024

Conversation

Latropos
Copy link
Contributor

@Latropos Latropos commented Apr 16, 2024

Summary

Implement skip and only for tests.
Especially only is important when creating new tests, since you generally want to add a decorator to your test instead of commenting out most of the file to run only one test.

  • only - if only decorator is used in any testfile, then only the decorater tests and suites will be executed
    • describe.only
    • test.only
    • test.only.each
  • skip - skip decorated tests and suites
    • describe.skip
    • test.skip
    • test.skip.each

Additionally the number of the skipped tests will be displayed.

Test plan

image

Testing code
describe('Big wardrobe', () => {
  test('Test of wardrobe', async () => {
    await render(<View />);
    expect(1).toBe(1);
  });

  describe('Shelf 1', () => {
    test('Test of Shelf 1', async () => {
      await render(<View />);
      expect(1).toBe(1);
    });
    describe('Box 1 on Shelf 1', () => {
      describe('Book 1 in the Box 1 on Shelf 1', () => {
        test('Test of Book 1 in the Box 1  on Shelf 1', async () => {
          await render(<View />);
          expect(1).toBe(1);
        });
      });
      describe('Book 2 in the Box 1 on Shelf 1', () => {
        test('Test of Book 2 in the Box 1  on Shelf 1', async () => {
          await render(<View />);
          expect(1).toBe(1);
        });
      });
    });
  });
  describe('Shelf 2', () => {
    test('Test of Shelf 2', async () => {
      await render(<View />);
      expect(1).toBe(1);
    });
  });
  describe('Shelf 3', () => {
    test('Test of Shelf 3', async () => {
      await render(<View />);
      expect(1).toBe(1);
    });
    describe('Box 1 on Shelf 3', () => {
      describe('Book 1 in the Box 1 on Shelf 3', () => {
        test('Test of Book 1 in the Box 1  on Shelf 3', async () => {
          await render(<View />);
          expect(1).toBe(1);
        });

        test.each(['Page1', 'Page2', 'Page3'])('Test of %p in Box 1 on Shelf 3', async () => {
          await render(<View />);
          expect(1).toBe(1);
        });
      });
      describe('Book 2 in the Box 1 on Shelf 3', () => {
        test('Test of Book 2 in the Box 1  on Shelf 3', async () => {
          await render(<View />);
          expect(1).toBe(1);
        });
      });
    });
  });
});

@Latropos Latropos marked this pull request as ready for review April 18, 2024 16:49
@Latropos Latropos requested a review from piaskowyk April 22, 2024 13:29
@Latropos Latropos requested a review from piaskowyk April 23, 2024 14:28
@Latropos Latropos requested a review from tjzel April 29, 2024 12:42
@Latropos Latropos added this pull request to the merge queue Apr 30, 2024
Merged via the queue into main with commit 67104b6 Apr 30, 2024
7 checks passed
@Latropos Latropos deleted the acynk/skip_and_only branch April 30, 2024 10:34
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.

None yet

2 participants