Skip to content

Jest async example needs an await https://basarat.gitbook.io/typescript/intro-1/jest #707

@AnupamKhosla

Description

@AnupamKhosla

https://basarat.gitbook.io/typescript/intro-1/jest

Following is wrong:

test('basic',async () => {
  expect(sum()).toBe(0);
});

test('basic again', async () => {
  expect(sum(1, 2)).toBe(3);
}, 1000 /* optional timeout */);

You need await like:

test('basic', async () => {
    expect(await sum()).toBe(0);
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions