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

Disallow explicitly returning from tests (no-test-return-statement)

Tests in Jest should be void and not return values.

If you are returning Promises then you should update the test to use async/await.

Rule details

This rule triggers a warning if you use a return statement inside of a test body.

/*eslint jest/no-test-return-statement: "error"*/

// valid:

it('noop', function () {});

test('noop', () => {});

test('one arrow', () => expect(1).toBe(1));

test('empty');

test('one', () => {
  expect(1).toBe(1);
});

it('one', function () {
  expect(1).toBe(1);
});

it('returning a promise', async () => {
  await new Promise(res => setTimeout(res, 100));
  expect(1).toBe(1);
});

// invalid:
test('return an expect', () => {
  return expect(1).toBe(1);
});

it('returning a promise', function () {
  return new Promise(res => setTimeout(res, 100)).then(() => expect(1).toBe(1));
});