You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First up awesome testing on the BE, well done. I referenced yours a lot!
Assertions: there are a couple of useful ones that you could use:
expect.assertions(number) verifies that a certain number of assertions are called during a test. This is often useful when testing asynchronous code, in order to make sure that assertions in a callback actually got called.`
.toHaveProperty(keyPath, value?) to check if property exists for an object (you can also check the value).
A describe block can be used to group tests. N.B this will affect the scope of your test when using beforeEach, afterAll etc.
describe("What tests are you grouping?", () => {
test("I am test 1"()=>{...})
})
Katia mentioned it might be nice to split out the model and handlers testing into seperate files. Looking for a solid example as a reference point and will add it when I see something worth following!
I'm sure you do this in your CI workflow but you can add a --coverage flag on the jest test script if you want a summary of code coverage.
The text was updated successfully, but these errors were encountered:
Thanks @Joepock123 . I've seen describe used in other people's tests but didn't understand what it actually did. As for splitting them out I'd love to but I started with them all in separate files and quickly ran into serious concurrency issues as all of our tests use the database. Right now all our route tests are actually integrations tests so I think I need to figure out how to use nock with supertest to mock out the database calls and turn them into unit tests. Oh for another week or two eh!
Ye describe is just a bit of sugar for organization! Interested that you tried separating out the files. Hopefully we'll still be in the QA Slack channel to keep on finger on the pulse!
First up awesome testing on the BE, well done. I referenced yours a lot!
Assertions: there are a couple of useful ones that you could use:
expect.assertions(number)
verifies that a certain number of assertions are called during a test. This is often useful when testing asynchronous code, in order to make sure that assertions in a callback actually got called.`.toHaveProperty(keyPath, value?)
to check if property exists for an object (you can also check the value).A
describe
block can be used to group tests. N.B this will affect the scope of your test when usingbeforeEach
,afterAll
etc.Katia mentioned it might be nice to split out the model and handlers testing into seperate files. Looking for a solid example as a reference point and will add it when I see something worth following!
I'm sure you do this in your CI workflow but you can add a
--coverage
flag on the jest test script if you want a summary of code coverage.The text was updated successfully, but these errors were encountered: