Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
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.

max-nested-describe.md 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. # Enforces a maximum depth to nested describe calls (`max-nested-describe`)
  2. While it's useful to be able to group your tests together within the same file
  3. using `describe()`, having too many levels of nesting throughout your tests make
  4. them difficult to read.
  5. ## Rule Details
  6. This rule enforces a maximum depth to nested `describe()` calls to improve code
  7. clarity in your tests.
  8. The following patterns are considered warnings (with the default option of
  9. `{ "max": 5 } `):
  10. ```js
  11. describe('foo', () => {
  12. describe('bar', () => {
  13. describe('baz', () => {
  14. describe('qux', () => {
  15. describe('quxx', () => {
  16. describe('too many', () => {
  17. it('should get something', () => {
  18. expect(getSomething()).toBe('Something');
  19. });
  20. });
  21. });
  22. });
  23. });
  24. });
  25. });
  26. describe('foo', function () {
  27. describe('bar', function () {
  28. describe('baz', function () {
  29. describe('qux', function () {
  30. describe('quxx', function () {
  31. describe('too many', function () {
  32. it('should get something', () => {
  33. expect(getSomething()).toBe('Something');
  34. });
  35. });
  36. });
  37. });
  38. });
  39. });
  40. });
  41. ```
  42. The following patterns are **not** considered warnings (with the default option
  43. of `{ "max": 5 } `):
  44. ```js
  45. describe('foo', () => {
  46. describe('bar', () => {
  47. it('should get something', () => {
  48. expect(getSomething()).toBe('Something');
  49. });
  50. });
  51. describe('qux', () => {
  52. it('should get something', () => {
  53. expect(getSomething()).toBe('Something');
  54. });
  55. });
  56. });
  57. describe('foo2', function () {
  58. it('should get something', () => {
  59. expect(getSomething()).toBe('Something');
  60. });
  61. });
  62. describe('foo', function () {
  63. describe('bar', function () {
  64. describe('baz', function () {
  65. describe('qux', function () {
  66. describe('this is the limit', function () {
  67. it('should get something', () => {
  68. expect(getSomething()).toBe('Something');
  69. });
  70. });
  71. });
  72. });
  73. });
  74. });
  75. ```
  76. ## Options
  77. ```json
  78. {
  79. "jest/max-nested-describe": [
  80. "error",
  81. {
  82. "max": 5
  83. }
  84. ]
  85. }
  86. ```
  87. ### `max`
  88. Enforces a maximum depth for nested `describe()`.
  89. This has a default value of `5`.
  90. Examples of patterns **not** considered warnings with options set to
  91. `{ "max": 2 }`:
  92. ```js
  93. describe('foo', () => {
  94. describe('bar', () => {
  95. it('should get something', () => {
  96. expect(getSomething()).toBe('Something');
  97. });
  98. });
  99. });
  100. describe('foo2', function()) {
  101. describe('bar2', function() {
  102. it('should get something', function() {
  103. expect(getSomething()).toBe('Something');
  104. });
  105. it('should get else', function() {
  106. expect(getSomething()).toBe('Something');
  107. });
  108. });
  109. });
  110. ```