Вы можете использовать прототип для расширения массива:
interface Array<T> {
remove(o: T): Array<T>;
}
Array.prototype.remove = function (o) {
// code to remove "o"
return this;
}
Вы можете использовать spyOn
, чтобы установить поведение функции get
:
const response = new Response ({headers: newHeaders});
const get = jest.spyOn(response.headers, 'get')
get.mockImplementation(()=> '')// do what ever `get` should to
Другой способ - не создать реальный Response
, а просто передать простой объект: [ 116]
const response = {
headers: {
get: jest.fn(()=> '')// do what ever `get` should to )
}
}