title: NestJs unit testing on typeorm pagination getting error queryBuilder.take(...).skip is not a function
body: <p>I am trying to mock createQueryBuilder to unit test pagination part, But i am getting below error</p>
  
  <blockquote>
    <p>queryBuilder.take(...).skip is not a function</p>
  </blockquote>
  
  <p>My Mock for createQueryBuilder </p>
  
  <pre><code>    createQueryBuilder: jest.fn(() =&gt; ({
        delete: jest.fn().mockReturnThis(),
        innerJoinAndSelect: jest.fn().mockReturnThis(),
        innerJoin: jest.fn().mockReturnThis(),
        from: jest.fn().mockReturnThis(),
        where: jest.fn().mockReturnThis(),
        execute: jest.fn().mockReturnThis(),
        getOne: jest.fn().mockReturnThis(),
        orderBy : jest.fn().mockReturnThis(),
        take : skip =&gt; ({
         skip: 5
        }), 
    }))
  </code></pre>
  
  <p>Unit Test for Find all</p>
  
  <pre><code>it("Find All", async () =&gt; {
      const pageData: PaginationDto = {
        page: 1,
        limit: 10,
        sortBy: "id",
        sortOrder: -1,
        relatinalData: relatinalData.no
  
      };
      expect(await service.getGroups(pageData)).toEqual({
        docs: [{
          groupName: "group123",
          description: "Group Description",
          roleId: 1
        },
        {
          groupName: "group123",
          description: "Group Description",
          roleId: 1
        }]
      });
  });
  </code></pre>
  
  <p>Services</p>
  
  <pre><code>import { paginate } from 'nestjs-typeorm-paginate';
  
  async getGroups(paginationDto: PaginationDto) {
          const pageOptions = await this.databaseService.preparePageData(paginationDto, 'groups');
          const queryBuilder = this.groupModel.createQueryBuilder('groups');
          const flag = paginationDto.relatinalData;
          if (relatinalData.yes === flag) {
              queryBuilder.leftJoinAndSelect("groups.role", "role");
          }
          queryBuilder.orderBy(pageOptions.order);
          pageOptions['route'] = environment.hostname + "groups";
          return await paginate(queryBuilder,pageOptions);
  }
  </code></pre>
  
  <p>Pagination page option Prepare function</p>
  
  <pre><code>async preparePageData(paginationDto, modelName) {
      const sort = {};
      if (paginationDto.sortBy &amp;&amp; paginationDto.sortOrder) {
          const sortValue = paginationDto.sortBy
          const sortOrder = paginationDto.sortOrder;
          if (paginationDto.relatinalData &amp;&amp; relatinalData.yes === paginationDto.relatinalData) {
              sort[modelName + '.' + sortValue] = sortOrder;
          } else {
              sort[sortValue] = sortOrder;
          }
      }
      const options = {
          page: paginationDto.page ? Number(paginationDto.page) : constant.pageLimit,
          limit: paginationDto.limit ? Number(paginationDto.limit) : constant.limit,
          order: sort ? sort : constant.sort
      };
      return options;
  }
  </code></pre>
  
  <p>Can any one please help me to mock <strong>nestjs-typeorm-paginate</strong></p>