Skip to content

[valid-expect] include fixer for adding missing await #1140

@jayu

Description

@jayu

How do you feel about making jest/valid-expect rule fixable for cases where await is missing ?

So adding await in front of expect in such cases:

it('should', async () => {
   expect(someAsyncThing).rejects.toBe(whatever)
})

//or 

it('should', async () => {
   expect(someAsyncThing).resolves.toBe(whatever)
})

Fixed code then would look like

it('should', async () => {
   await expect(someAsyncThing).rejects.toBe(whatever)
})

//or 

it('should', async () => {
   await expect(someAsyncThing).resolves.toBe(whatever)
})

I'm happy to give it a try if there is a chance it will be merged :)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions