function failRequestsForTarget(
      netEngine, targetUri, errorCode=shaka.util.Error.Code.BAD_HTTP_STATUS) {
    // eslint-disable-next-line no-restricted-syntax
    const originalNetEngineRequest = netEngine.request.bind(netEngine);

    netEngine.request = jasmine.createSpy('request').and.callFake(
        (requestType, request) => {
          if (request.uris[0] == targetUri) {
            const data = [targetUri];

            if (errorCode == shaka.util.Error.Code.BAD_HTTP_STATUS ||
                errorCode == shaka.util.Error.Code.SEGMENT_MISSING) {
              data.push(404);
              data.push('');
            }

            // The compiler still sees the error code parameter as potentially
            // undefined, even though we gave it a default value.
            goog.asserts.assert(errorCode != undefined, 'Undefined error code');

            return shaka.util.AbortableOperation.failed(new shaka.util.Error(
                shaka.util.Error.Severity.CRITICAL,
                shaka.util.Error.Category.NETWORK,
                errorCode, data));
          }
          return originalNetEngineRequest(requestType, request);
        });
  }
@param {!shaka.test.FakeNetworkingEngine} netEngine A NetworkingEngine
  look-alike.
@param {string} targetUri
@param {shaka.util.Error.Code=} errorCode