web 3d图形渲染器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.3 KiB

  1. # Require test cases and hooks to be inside a `describe` block (`require-top-level-describe`)
  2. Jest allows you to organise your test files the way you want it. However, the
  3. more your codebase grows, the more it becomes hard to navigate in your test
  4. files. This rule makes sure you provide at least a top-level `describe` block in
  5. your test file.
  6. ## Rule Details
  7. This rule triggers a warning if a test case (`test` and `it`) or a hook
  8. (`beforeAll`, `beforeEach`, `afterEach`, `afterAll`) is not located in a
  9. top-level `describe` block.
  10. The following patterns are considered warnings:
  11. ```js
  12. // Above a describe block
  13. test('my test', () => {});
  14. describe('test suite', () => {
  15. it('test', () => {});
  16. });
  17. // Below a describe block
  18. describe('test suite', () => {});
  19. test('my test', () => {});
  20. // Same for hooks
  21. beforeAll('my beforeAll', () => {});
  22. describe('test suite', () => {});
  23. afterEach('my afterEach', () => {});
  24. ```
  25. The following patterns are **not** considered warnings:
  26. ```js
  27. // In a describe block
  28. describe('test suite', () => {
  29. test('my test', () => {});
  30. });
  31. // In a nested describe block
  32. describe('test suite', () => {
  33. test('my test', () => {});
  34. describe('another test suite', () => {
  35. test('my other test', () => {});
  36. });
  37. });
  38. ```
  39. ## When Not To Use It
  40. Don't use this rule on non-jest test files.