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.
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
describeblock can be used to group tests. N.B this will affect the scope of your test when usingbeforeEach,afterAlletc.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
--coverageflag on the jest test script if you want a summary of code coverage.