Function notRejects

  • check if promise rejects

    Parameters

    • promise: Promise<any>
    • Optionalmessage: string

    Returns Promise<void>

    rejects(Promise.reject());
    
  • check if promise rejects with an instance of constructor

    Parameters

    • promise: Promise<any>
    • constructor: Constructor<any>

      expected error constructor

    • Optionalmessage: string

    Returns Promise<void>

    rejects(Promise.reject(new Error()), Error);
    
  • check if promise rejects with a specific error message

    Parameters

    • promise: Promise<any>
    • constructor: RegExp
    • Optionalmessage: string

    Returns Promise<void>

    rejects(Promise.reject(new Error('This is worrying)), /worrying/);
    
  • check if promise rejects with and matches the predicate function

    Parameters

    • promise: Promise<any>
    • constructor: ErrorPredicate
    • Optionalmessage: string

    Returns Promise<void>

    rejects(Promise.reject(new Error('This is worrying')), (error) => error.message === 'This is worrying');));