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.

no-test-return-statement.md 913B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # Disallow explicitly returning from tests (`no-test-return-statement`)
  2. Tests in Jest should be void and not return values.
  3. If you are returning Promises then you should update the test to use
  4. `async/await`.
  5. ## Rule details
  6. This rule triggers a warning if you use a return statement inside of a test
  7. body.
  8. ```js
  9. /*eslint jest/no-test-return-statement: "error"*/
  10. // valid:
  11. it('noop', function () {});
  12. test('noop', () => {});
  13. test('one arrow', () => expect(1).toBe(1));
  14. test('empty');
  15. test('one', () => {
  16. expect(1).toBe(1);
  17. });
  18. it('one', function () {
  19. expect(1).toBe(1);
  20. });
  21. it('returning a promise', async () => {
  22. await new Promise(res => setTimeout(res, 100));
  23. expect(1).toBe(1);
  24. });
  25. // invalid:
  26. test('return an expect', () => {
  27. return expect(1).toBe(1);
  28. });
  29. it('returning a promise', function () {
  30. return new Promise(res => setTimeout(res, 100)).then(() => expect(1).toBe(1));
  31. });
  32. ```