Websites v4 docs v5.2.5
    Preparing search index...

    Function dbapiMockErrorResponse

    • Function to reduce repeated code in dbapi tests. Tests of model statics that rely on the dbapi client should include a test for the api returning an error, resulting in a lot of repeated code across test files.

      Eg.

        it('returns an error if the api responds with an error', async () => {
      dbapiMockErrorResponse('connections', server);

      const { results, errors } = await Connection.findAll();

      expect(errors).not.toBeNull();
      expect(results).toHaveLength(0);
      expect(errors?.[0].message).toBe('Something went wrong');
      });

      Parameters

      • path: string
      • server: SetupServer

      Returns void