Code coverage report for node-request-retry/strategies/NetworkError.js

# All files / node-request-retry/strategies NetworkError.js

100% Statements 5/5
100% Branches 2/2
100% Functions 1/1
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17

    1x
    1x

    58x

    1x
    1x
     'use strict';

    var RETRIABLE_ERRORS = ['ECONNRESET', 'ENOTFOUND', 'ESOCKETTIMEDOUT', 'ETIMEDOUT', 'ECONNREFUSED', 'EHOSTUNREACH', 'EPIPE', 'EAI_AGAIN'];
    var _ = require('lodash');

    /**
     * @param  {Null | Object} err
     * @param  {Object} response
     * @return {Boolean} true if the request had a network error
     */
    function NetworkError(err /*, response*/ ) {
      return err && _.includes(RETRIABLE_ERRORS, err.code);
    }

    NetworkError.RETRIABLE_ERRORS = RETRIABLE_ERRORS;
    module.exports = NetworkError;