Last active
December 30, 2018 07:25
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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