Skip to content

Refactor assert error test case in the unit tests #687

@bonnie57

Description

@bonnie57

In the project, we have many test cases wrapped in try-catch. In the error situation, the assertion error test cases can pass. But if the test case passes, the test case cannot assert to fail to notify the developer.

Previous error test case

it(xxx,()=>{
    try {
      method()
    }catch {
    expect(xxxx)
  }
})

Prefer

it(xxx,()=>{
   await expect(method).to.be.rejectedWith(xxx)
  }
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions