title: Cover abstract class method with tests in Jest
body: <p>I have generic service class which is abstract.</p>
  
  <pre><code>export default abstract class GenericService&lt;Type&gt; implements CrudService&lt;Type&gt; {
      private readonly modifiedUrl: URL;
  
      public constructor(url: string) {
          this.modifiedUrl = new URL(url, window.location.href);
      }
  
      public async get(path?: string, filter?: URLSearchParams): Promise&lt;Type&gt; {
          try {
              if (path) {
                  this.modifiedUrl.href += `${path}`;
              }
              addQueryParams(this.modifiedUrl, filter);
  
              const response = await handleRequest(`${this.modifiedUrl}`, getFetchOptions('GET'));
              const data = await response.json();
              return (await data.data) ? data.data : data;
          } catch (error) {
              throw new Error(`Runtime error: ${error}`);
          }
      }
  }
  
  export async function handleRequest(input: RequestInfo, init: RequestInit): Promise&lt;Response&gt; {
      const response = await fetch(input, init);
  
      if (!response.ok) {
          throw new Error(`Network response was not ok: ${response}`);
      }
  
      return response;
  }
  </code></pre>
  
  <p>I need to cover this <code>GenericService</code>'s <code>get</code> method with tests. I've tried this:</p>
  
  <pre><code>jest.mock('../../components/crudTable/service/GenericService');
  const genericService = GenericService;
  
  export class DummyClass {
      public name: string = '';
  }
  export class DummyService extends GenericService&lt;DummyClass&gt; {}
  
  describe('Generic Service', () =&gt; {
      it('1- spy prototype function', async () =&gt; {
          const spy = jest.spyOn(genericService.prototype, 'get');
          await genericService.prototype.get();
          expect(spy).toHaveBeenCalledTimes(1);
      });
      it('2- mock prototype function', async () =&gt; {
          const mockFn = jest.fn(genericService.prototype.get);
          await mockFn();
          expect(mockFn).toHaveBeenCalledTimes(1);
      });
      it('3- mock subclass function', async () =&gt; {
          const dummyService = new DummyService('test url');
          const mockFn = jest.fn(dummyService.get);
          await mockFn();
          expect(mockFn).toHaveBeenCalledTimes(1);
      });
  });
  </code></pre>
  
  <p>This test works but the coverage stats says that it is still not covered. 
  So how can I covert the all <code>get</code> method of <code>GenericService</code>?</p>