title: Mocking Express Request with Jest and Typescript using correct types
body: <p>I have been having some trouble getting the correct Express Request type working in Jest. I have a simple user registration passing with this code:</p>
  
  <pre><code>import { userRegister } from '../../controllers/user';
  import { Request, Response, NextFunction } from 'express';
  
  describe('User Registration', () =&gt; {
    test('User has an invalid first name', async () =&gt; {
      const mockRequest: any = {
        body: {
          firstName: 'J',
          lastName: 'Doe',
          email: 'jdoe@abc123.com',
          password: 'Abcd1234',
          passwordConfirm: 'Abcd1234',
          company: 'ABC Inc.',
        },
      };
  
      const mockResponse: any = {
        json: jest.fn(),
        status: jest.fn(),
      };
  
      const mockNext: NextFunction = jest.fn();
  
      await userRegister(mockRequest, mockResponse, mockNext);
  
      expect(mockNext).toHaveBeenCalledTimes(1);
      expect(mockNext).toHaveBeenCalledWith(
        new Error('First name must be between 2 and 50 characters')
      );
    });
  });
  </code></pre>
  
  <p>However, if I change:</p>
  
  <pre><code>    const mockRequest: any = {
        body: {
          firstName: 'J',
          lastName: 'Doe',
          email: 'jdoe@abc123.com',
          password: 'Abcd1234',
          passwordConfirm: 'Abcd1234',
          company: 'ABC Inc.',
        },
      };
  </code></pre>
  
  <p>to:</p>
  
  <pre><code>const mockRequest: Partial&lt;Request&gt; = {
    body: {
      firstName: 'J',
      lastName: 'Doe',
      email: 'jdoe@abc123.com',
      password: 'Abcd1234',
      passwordConfirm: 'Abcd1234',
      company: 'ABC Inc.',
    },
  };
  </code></pre>
  
  <p>From the TypeScript documentation (<a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#partialt" rel="noreferrer">https://www.typescriptlang.org/docs/handbook/utility-types.html#partialt</a>), this should make all fields on the Request object optional.</p>
  
  <p>However, I get this error:</p>
  
  <pre><code>Argument of type 'Partial&lt;Request&gt;' is not assignable to parameter of type 'Request'.
    Property '[Symbol.asyncIterator]' is missing in type 'Partial&lt;Request&gt;' but required in type 'Request'.ts(2345)
  stream.d.ts(101, 13): '[Symbol.asyncIterator]' is declared here.
  </code></pre>
  
  <p>I was hoping that someone with a little more TypeScript experience could comment and let me know what I am doing wrong.</p>