Skip to content

🔬 Testing: move towards a more explicit approach #1870

@cameron-robey

Description

@cameron-robey

Our current testing is full of a mixture of mocks and handlers that are either called explicitly, or run under the hood for all tests. An example of something called explicitly are runInTmpDir(), and something not called explicitly is the mocking of fetch by jest (which is in works to be replaced by MSW in the eventual move to vitest).

The approach we want to move towards is the explicit approach: we want to know all the behaviour change that might be present in a test by reading the test.

In essence, a new test written with no mocks or handlers called should run the test exactly as expected. In order to mock things or change behaviour we called a hook or equivalent to enable it for that particular test or suite of tests.

This will make our tests more verbose, however this is a tradeoff worth making to make it much easier to read and develop tests (especially for those unfamiliar with our codebase).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions