Skip to content

Testing #45

Description

@Joepock123

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:

  1. 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.`
  2. .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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions