Skip to content

Instantly share code, notes, and snippets.

@goldbergyoni
Last active December 30, 2018 07:25
Show Gist options
  • Select an option

  • Save goldbergyoni/b118db1eb80c20e0228835c2ae42db0e to your computer and use it in GitHub Desktop.

Select an option

Save goldbergyoni/b118db1eb80c20e0228835c2ae42db0e to your computer and use it in GitHub Desktop.
Anti-pattern Example: A long test case that tries to assert the existence of error with try-catch
it("When no product name, it throws error 400", async() => {
let errorWeExceptFor = null;
try {
const result = await addNewProduct({name:'nest'});}
catch (error) {
expect(error.code).to.equal('InvalidInput');
errorWeExceptFor = error;
}
expect(errorWeExceptFor).not.to.be.null;
//if this assertion fails, the tests results/reports will only show
//that some value is null, there won't be a word about a missing Exception
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment