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.

valid-describe.md 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # Enforce valid `describe()` callback (`valid-describe`)
  2. Using an improper `describe()` callback function can lead to unexpected test
  3. errors.
  4. ## Rule Details
  5. This rule validates that the second parameter of a `describe()` function is a
  6. callback function. This callback function:
  7. - should not be
  8. [async](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function)
  9. - should not contain any parameters
  10. - should not contain any `return` statements
  11. The following `describe` function aliases are also validated:
  12. - `describe`
  13. - `describe.only`
  14. - `describe.skip`
  15. - `fdescribe`
  16. - `xdescribe`
  17. The following patterns are considered warnings:
  18. ```js
  19. // Async callback functions are not allowed
  20. describe('myFunction()', async () => {
  21. // ...
  22. });
  23. // Callback function parameters are not allowed
  24. describe('myFunction()', done => {
  25. // ...
  26. });
  27. //
  28. describe('myFunction', () => {
  29. // No return statements are allowed in block of a callback function
  30. return Promise.resolve().then(() => {
  31. it('breaks', () => {
  32. throw new Error('Fail');
  33. });
  34. });
  35. });
  36. // Returning a value from a describe block is not allowed
  37. describe('myFunction', () =>
  38. it('returns a truthy value', () => {
  39. expect(myFunction()).toBeTruthy();
  40. }));
  41. ```
  42. The following patterns are not considered warnings:
  43. ```js
  44. describe('myFunction()', () => {
  45. it('returns a truthy value', () => {
  46. expect(myFunction()).toBeTruthy();
  47. });
  48. });
  49. ```