From f6fbd6c94d86d54ee13d20f0128589332cbddcbf Mon Sep 17 00:00:00 2001
From: Artem Zakharchenko <kettanaito@gmail.com>
Date: Sat, 30 Oct 2021 13:51:16 +0200
Subject: [PATCH] chore: use "res.allHeaders()" instead of "res.headers()"

---
 test/graphql-api/cookies.test.ts                     |  2 +-
 test/graphql-api/document-node.test.ts               |  6 +++---
 test/graphql-api/link.test.ts                        |  6 +++---
 test/graphql-api/mutation.test.ts                    |  2 +-
 test/graphql-api/operation-reference.test.ts         |  4 ++--
 test/graphql-api/operation.test.ts                   |  8 ++++----
 test/graphql-api/query.test.ts                       |  4 ++--
 .../context/async-response-transformer.test.ts       |  4 ++--
 test/msw-api/context/delay.test.ts                   |  6 +++---
 test/msw-api/exception-handling.test.ts              |  2 +-
 test/msw-api/hard-reload.test.ts                     |  2 +-
 test/msw-api/integrity-check.test.ts                 |  4 ++--
 test/msw-api/setup-worker/start/quiet.test.ts        |  2 +-
 test/msw-api/setup-worker/stop.test.ts               |  4 ++--
 test/rest-api/basic.test.ts                          |  3 ++-
 test/rest-api/context.test.ts                        |  2 +-
 test/rest-api/cookies-request.test.ts                |  8 ++++----
 test/rest-api/cookies.test.ts                        |  2 +-
 test/rest-api/custom-request-handler.test.ts         |  4 ++--
 test/rest-api/generator.test.ts                      |  4 ++--
 test/rest-api/headers-multiple.test.ts               |  2 +-
 test/rest-api/params.test.ts                         |  2 +-
 test/rest-api/query.test.ts                          |  4 ++--
 test/rest-api/redirect.test.ts                       |  7 ++++---
 test/rest-api/request/matching/method.test.ts        |  4 ++--
 test/rest-api/request/matching/uri.test.ts           | 12 ++++++------
 test/rest-api/response-patching.test.ts              | 10 +++++-----
 test/rest-api/response/body/body-binary.test.ts      |  2 +-
 test/rest-api/response/body/body-json.test.ts        |  2 +-
 test/rest-api/response/body/body-text.test.ts        |  2 +-
 test/rest-api/response/body/body-xml.test.ts         |  2 +-
 31 files changed, 65 insertions(+), 63 deletions(-)

diff --git a/test/graphql-api/cookies.test.ts b/test/graphql-api/cookies.test.ts
index 088698948..33d86850d 100644
--- a/test/graphql-api/cookies.test.ts
+++ b/test/graphql-api/cookies.test.ts
@@ -19,7 +19,7 @@ test('sets cookie on the mocked GraphQL response', async () => {
     `,
   })
 
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(headers).toHaveProperty('x-powered-by', 'msw')
diff --git a/test/graphql-api/document-node.test.ts b/test/graphql-api/document-node.test.ts
index 9e908a876..3a4f8e5ba 100644
--- a/test/graphql-api/document-node.test.ts
+++ b/test/graphql-api/document-node.test.ts
@@ -23,7 +23,7 @@ test('intercepts a GraphQL query based on its DocumentNode', async () => {
   })
 
   expect(res.status()).toEqual(200)
-  expect(res.headers()).toHaveProperty('x-powered-by', 'msw')
+  expect(await res.allHeaders()).toHaveProperty('x-powered-by', 'msw')
 
   const json = await res.json()
   expect(json).toEqual({
@@ -52,7 +52,7 @@ test('intercepts a GraphQL mutation based on its DocumentNode', async () => {
   })
 
   expect(res.status()).toEqual(200)
-  expect(res.headers()).toHaveProperty('x-powered-by', 'msw')
+  expect(await res.allHeaders()).toHaveProperty('x-powered-by', 'msw')
 
   const json = await res.json()
   expect(json).toEqual({
@@ -87,7 +87,7 @@ test('intercepts a scoped GraphQL query based on its DocumentNode', async () =>
   )
 
   expect(res.status()).toEqual(200)
-  expect(res.headers()).toHaveProperty('x-powered-by', 'msw')
+  expect(await res.allHeaders()).toHaveProperty('x-powered-by', 'msw')
 
   const json = await res.json()
   expect(json).toEqual({
diff --git a/test/graphql-api/link.test.ts b/test/graphql-api/link.test.ts
index 9c62330c5..5cdc193df 100644
--- a/test/graphql-api/link.test.ts
+++ b/test/graphql-api/link.test.ts
@@ -36,7 +36,7 @@ test('mocks a GraphQL query to the GitHub GraphQL API', async () => {
     },
   )
 
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(res.status()).toEqual(200)
@@ -73,7 +73,7 @@ test('mocks a GraphQL mutation to the Stripe GraphQL API', async () => {
     },
   )
 
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(res.status()).toEqual(200)
@@ -104,7 +104,7 @@ test('falls through to the matching GraphQL operation to an unknown endpoint', a
     },
   })
 
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(headers).toHaveProperty('x-request-handler', 'fallback')
diff --git a/test/graphql-api/mutation.test.ts b/test/graphql-api/mutation.test.ts
index afa6b3fb8..9f11b7bf2 100644
--- a/test/graphql-api/mutation.test.ts
+++ b/test/graphql-api/mutation.test.ts
@@ -23,7 +23,7 @@ test('sends a mocked response to a GraphQL mutation', async () => {
       }
     `,
   })
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(res.status()).toEqual(200)
diff --git a/test/graphql-api/operation-reference.test.ts b/test/graphql-api/operation-reference.test.ts
index 65101c7d2..0f7deac0a 100644
--- a/test/graphql-api/operation-reference.test.ts
+++ b/test/graphql-api/operation-reference.test.ts
@@ -23,7 +23,7 @@ test('allows referencing the request body in the request handler', async () => {
       id: 'abc-123',
     },
   })
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(headers).toHaveProperty('x-powered-by', 'msw')
@@ -53,7 +53,7 @@ test('allows referencing the request body in the request handler', async () => {
       password: 'super-secret',
     },
   })
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(headers).toHaveProperty('x-powered-by', 'msw')
diff --git a/test/graphql-api/operation.test.ts b/test/graphql-api/operation.test.ts
index 62d6d6c00..fc57cee79 100644
--- a/test/graphql-api/operation.test.ts
+++ b/test/graphql-api/operation.test.ts
@@ -30,7 +30,7 @@ test('intercepts and mocks a GraphQL query', async () => {
       id: 'abc-123',
     },
   })
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(res.status()).toEqual(200)
@@ -73,7 +73,7 @@ test('intercepts and mocks an anonymous GraphQL query', async () => {
 
   expect(res.status()).toEqual(200)
 
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   expect(headers).toHaveProperty('x-powered-by', 'msw')
 
   const body = await res.json()
@@ -109,7 +109,7 @@ test('intercepts and mocks a GraphQL mutation', async () => {
       password: 'super-secret',
     },
   })
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(res.status()).toEqual(200)
@@ -163,7 +163,7 @@ test('bypasses seemingly compatible REST requests', async () => {
     },
   )
 
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(res.status()).toBe(200)
diff --git a/test/graphql-api/query.test.ts b/test/graphql-api/query.test.ts
index c26c7c0d1..7e388d631 100644
--- a/test/graphql-api/query.test.ts
+++ b/test/graphql-api/query.test.ts
@@ -31,7 +31,7 @@ test('mocks a GraphQL query issued with a GET request', async () => {
     },
   )
 
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(res.status()).toEqual(200)
@@ -59,7 +59,7 @@ test('mocks a GraphQL query issued with a POST request', async () => {
       }
     `,
   })
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(res.status()).toEqual(200)
diff --git a/test/msw-api/context/async-response-transformer.test.ts b/test/msw-api/context/async-response-transformer.test.ts
index 1255beb2a..fbb26ed1a 100644
--- a/test/msw-api/context/async-response-transformer.test.ts
+++ b/test/msw-api/context/async-response-transformer.test.ts
@@ -13,7 +13,7 @@ test('supports asynchronous response transformer', async () => {
     path.resolve(__dirname, '../../fixtures/image.jpg'),
   )
   const status = res.status()
-  const headers = res.headers()
+  const headers = await res.allHeaders()
 
   expect(status).toBe(201)
   expect(headers).toHaveProperty('content-type', 'image/jpeg')
@@ -34,7 +34,7 @@ test('supports asynchronous default response transformer', async () => {
   })
   const status = res.status()
   const statusText = res.statusText()
-  const headers = res.headers()
+  const headers = await res.allHeaders()
 
   expect(status).toBe(301)
   expect(statusText).toBe('Custom Status Text')
diff --git a/test/msw-api/context/delay.test.ts b/test/msw-api/context/delay.test.ts
index a7da16651..c9b7257d6 100644
--- a/test/msw-api/context/delay.test.ts
+++ b/test/msw-api/context/delay.test.ts
@@ -54,7 +54,7 @@ test('uses explicit server response delay', async () => {
   expect(responseTime).toRoughlyEqual(1200, 250)
 
   const status = res.status()
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(headers).toHaveProperty('x-powered-by', 'msw')
@@ -74,7 +74,7 @@ test('uses realistic server response delay when no delay value is provided', asy
   expect(responseTime).toRoughlyEqual(250, 200)
 
   const status = res.status()
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(headers).toHaveProperty('x-powered-by', 'msw')
@@ -96,7 +96,7 @@ test('uses realistic server response delay when "real" delay mode is provided',
   expect(responseTime).toRoughlyEqual(250, 200)
 
   const status = res.status()
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(headers).toHaveProperty('x-powered-by', 'msw')
diff --git a/test/msw-api/exception-handling.test.ts b/test/msw-api/exception-handling.test.ts
index a798dcf9d..5809115d6 100644
--- a/test/msw-api/exception-handling.test.ts
+++ b/test/msw-api/exception-handling.test.ts
@@ -17,7 +17,7 @@ test('transforms uncaught exceptions into a 500 response', async () => {
 
   const res = await runtime.request('https://api.github.com/users/octocat')
   const status = res.status()
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(status).toEqual(500)
diff --git a/test/msw-api/hard-reload.test.ts b/test/msw-api/hard-reload.test.ts
index 0c365aef7..0efa50faa 100644
--- a/test/msw-api/hard-reload.test.ts
+++ b/test/msw-api/hard-reload.test.ts
@@ -18,7 +18,7 @@ test('keeps the mocking enabled after hard-reload of the page', async () => {
   })
 
   const res = await runtime.request('https://api.github.com')
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(headers).toHaveProperty('x-powered-by', 'msw')
diff --git a/test/msw-api/integrity-check.test.ts b/test/msw-api/integrity-check.test.ts
index 34228d083..cf4285177 100644
--- a/test/msw-api/integrity-check.test.ts
+++ b/test/msw-api/integrity-check.test.ts
@@ -20,7 +20,7 @@ test('activates the worker without errors given the latest integrity', async ()
   expect(consoleSpy.get('error')).toBeUndefined()
 
   const res = await request('https://api.github.com/users/octocat')
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(headers).toHaveProperty('x-powered-by', 'msw')
@@ -63,7 +63,7 @@ test('errors when activating the worker with an outdated integrity', async () =>
 
   // Should still keep the mocking enabled.
   const res = await request('https://api.github.com/users/octocat')
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(headers).toHaveProperty('x-powered-by', 'msw')
diff --git a/test/msw-api/setup-worker/start/quiet.test.ts b/test/msw-api/setup-worker/start/quiet.test.ts
index f5fadeeec..70b7507be 100644
--- a/test/msw-api/setup-worker/start/quiet.test.ts
+++ b/test/msw-api/setup-worker/start/quiet.test.ts
@@ -21,7 +21,7 @@ test('does not log the captured request when the "quiet" option is set to "true"
 
   const res = await request('/user')
 
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(headers).toHaveProperty('x-powered-by', 'msw')
diff --git a/test/msw-api/setup-worker/stop.test.ts b/test/msw-api/setup-worker/stop.test.ts
index 8cc3ac3b7..a81578b0a 100644
--- a/test/msw-api/setup-worker/stop.test.ts
+++ b/test/msw-api/setup-worker/stop.test.ts
@@ -28,7 +28,7 @@ test('disables the mocking when the worker is stopped', async () => {
   await stopWorkerOn(runtime.page)
 
   const res = await runtime.request('https://api.github.com')
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(headers).not.toHaveProperty('x-powered-by', 'msw')
@@ -56,7 +56,7 @@ test('keeps the mocking enabled in one tab when stopping the worker in another t
   // Create a request handler for the new page.
   const request = createRequestUtil(secondPage, server)
   const res = await request('https://api.github.com')
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(headers).toHaveProperty('x-powered-by', 'msw')
diff --git a/test/rest-api/basic.test.ts b/test/rest-api/basic.test.ts
index 25adbee7a..840c0b9e7 100644
--- a/test/rest-api/basic.test.ts
+++ b/test/rest-api/basic.test.ts
@@ -7,10 +7,11 @@ test('mocks response to a basic GET request', async () => {
   })
 
   const res = await runtime.request('https://api.github.com/users/octocat')
+  const headers = await res.allHeaders()
   const body = await res.json()
 
-  expect(res.headers()).toHaveProperty('x-powered-by', 'msw')
   expect(res.status()).toBe(200)
+  expect(headers).toHaveProperty('x-powered-by', 'msw')
   expect(body).toEqual({
     name: 'John Maverick',
     originalUsername: 'octocat',
diff --git a/test/rest-api/context.test.ts b/test/rest-api/context.test.ts
index 50a6c4088..f930f621e 100644
--- a/test/rest-api/context.test.ts
+++ b/test/rest-api/context.test.ts
@@ -7,7 +7,7 @@ test('composes various context utilities into a valid mocked response', async ()
   })
 
   const res = await runtime.request('https://test.mswjs.io/')
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(res.status()).toEqual(201)
diff --git a/test/rest-api/cookies-request.test.ts b/test/rest-api/cookies-request.test.ts
index 0300c146d..b8efd6937 100644
--- a/test/rest-api/cookies-request.test.ts
+++ b/test/rest-api/cookies-request.test.ts
@@ -18,7 +18,7 @@ test('returns all document cookies in "req.cookies" for "include" credentials',
   const res = await runtime.request('/user', {
     credentials: 'include',
   })
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(headers).toHaveProperty('x-powered-by', 'msw')
@@ -36,7 +36,7 @@ test('returns all document cookies in "req.cookies" for "same-origin" credential
   const res = await runtime.request('/user', {
     credentials: 'same-origin',
   })
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(headers).toHaveProperty('x-powered-by', 'msw')
@@ -54,7 +54,7 @@ test('returns no cookies in "req.cookies" for "same-origin" credentials and requ
   const res = await runtime.request('https://test.mswjs.io/user', {
     credentials: 'same-origin',
   })
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(headers).toHaveProperty('x-powered-by', 'msw')
@@ -69,7 +69,7 @@ test('returns no cookies in "req.cookies" for "omit" credentials', async () => {
   const res = await runtime.request('/user', {
     credentials: 'omit',
   })
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(headers).toHaveProperty('x-powered-by', 'msw')
diff --git a/test/rest-api/cookies.test.ts b/test/rest-api/cookies.test.ts
index d16ba0b25..75472f2a1 100644
--- a/test/rest-api/cookies.test.ts
+++ b/test/rest-api/cookies.test.ts
@@ -11,7 +11,7 @@ test('allows setting cookies on the mocked response', async () => {
 
   const res = await runtime.request('/user')
 
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(headers).toHaveProperty('x-powered-by', 'msw')
diff --git a/test/rest-api/custom-request-handler.test.ts b/test/rest-api/custom-request-handler.test.ts
index d980841a8..d0f7f5965 100644
--- a/test/rest-api/custom-request-handler.test.ts
+++ b/test/rest-api/custom-request-handler.test.ts
@@ -16,7 +16,7 @@ test('intercepts a request with a custom request handler with default context',
     },
   })
   const body = await res.json()
-  const headers = res.headers()
+  const headers = await res.allHeaders()
 
   expect(res.status()).toBe(401)
   expect(headers).toHaveProperty('x-powered-by', 'msw')
@@ -30,7 +30,7 @@ test('intercepts a request with a custom request handler with custom context', a
 
   const res = await runtime.request('https://test.url/')
   const body = await res.json()
-  const headers = res.headers()
+  const headers = await res.allHeaders()
 
   expect(res.status()).toBe(200)
   expect(headers).toHaveProperty('x-powered-by', 'msw')
diff --git a/test/rest-api/generator.test.ts b/test/rest-api/generator.test.ts
index 43978e5dc..171559fd9 100644
--- a/test/rest-api/generator.test.ts
+++ b/test/rest-api/generator.test.ts
@@ -18,7 +18,7 @@ test('supports a generator function as the response resolver', async () => {
   const assertRequest = async (expectedBody: ExpectedResponseBody) => {
     const res = await runtime.request('/polling/3')
     const body = await res.json()
-    expect(res.headers()).toHaveProperty('x-powered-by', 'msw')
+    expect(await res.allHeaders()).toHaveProperty('x-powered-by', 'msw')
     expect(res.status()).toBe(200)
     expect(body).toEqual(expectedBody)
   }
@@ -39,7 +39,7 @@ test('supports one-time handlers with the generator as the response resolver', a
   const assertRequest = async (expectedBody: ExpectedResponseBody) => {
     const res = await runtime.request('/polling/once/3')
     const body = await res.json()
-    expect(res.headers()).toHaveProperty('x-powered-by', 'msw')
+    expect(await res.allHeaders()).toHaveProperty('x-powered-by', 'msw')
     expect(res.status()).toBe(200)
     expect(body).toEqual(expectedBody)
   }
diff --git a/test/rest-api/headers-multiple.test.ts b/test/rest-api/headers-multiple.test.ts
index 4dfd895cd..2dd78f5f2 100644
--- a/test/rest-api/headers-multiple.test.ts
+++ b/test/rest-api/headers-multiple.test.ts
@@ -34,7 +34,7 @@ test('supports setting a header with multiple values on the mocked response', as
 
   const res = await runtime.request('https://test.mswjs.io')
   const status = res.status()
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(status).toEqual(200)
diff --git a/test/rest-api/params.test.ts b/test/rest-api/params.test.ts
index bda9c83f9..be65caca8 100644
--- a/test/rest-api/params.test.ts
+++ b/test/rest-api/params.test.ts
@@ -10,7 +10,7 @@ test('parses request URL parameters', async () => {
     'https://api.github.com/users/octocat/messages/abc-123',
   )
   const status = res.status()
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(status).toBe(200)
diff --git a/test/rest-api/query.test.ts b/test/rest-api/query.test.ts
index dd166fb08..0b927d3dc 100644
--- a/test/rest-api/query.test.ts
+++ b/test/rest-api/query.test.ts
@@ -14,7 +14,7 @@ test('retrieves a single request URL query parameter', async () => {
     'https://test.mswjs.io/api/books?id=abc-123',
   )
   const status = res.status()
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(status).toBe(200)
@@ -34,7 +34,7 @@ test('retrieves multiple request URL query parameters', async () => {
     },
   )
   const status = res.status()
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(status).toBe(200)
diff --git a/test/rest-api/redirect.test.ts b/test/rest-api/redirect.test.ts
index 7128a9228..11f794135 100644
--- a/test/rest-api/redirect.test.ts
+++ b/test/rest-api/redirect.test.ts
@@ -6,17 +6,18 @@ test('supports redirect in a mocked response', async () => {
     example: path.resolve(__dirname, 'redirect.mocks.ts'),
   })
   const res = await runtime.request('/login')
+  const headers = await res.allHeaders()
 
   // Assert the original response returns redirect.
-  expect(res.headers()).toHaveProperty('location', '/user')
-  expect(res.headers()).toHaveProperty('x-powered-by', 'msw')
+  expect(headers).toHaveProperty('location', '/user')
+  expect(headers).toHaveProperty('x-powered-by', 'msw')
   expect(res.status()).toBe(307)
 
   const redirectRes = await runtime.page.waitForResponse(
     runtime.makeUrl('/user'),
   )
   const redirectStatus = redirectRes.status()
-  const redirectHeaders = redirectRes.headers()
+  const redirectHeaders = await redirectRes.allHeaders()
   const redirectBody = await redirectRes.json()
 
   // Assert redirect gets requested and mocked.
diff --git a/test/rest-api/request/matching/method.test.ts b/test/rest-api/request/matching/method.test.ts
index ea4f9f6fe..04d458095 100644
--- a/test/rest-api/request/matching/method.test.ts
+++ b/test/rest-api/request/matching/method.test.ts
@@ -12,7 +12,7 @@ test('sends a mocked response to a POST request on the matching URL', async () =
     method: 'POST',
   })
   const status = res.status()
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(status).toBe(200)
@@ -27,7 +27,7 @@ test('does not send a mocked response to a GET request on the matching URL', asy
 
   const res = await runtime.request('https://api.github.com/users/octocat')
   const status = res.status()
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(status).toBe(200)
diff --git a/test/rest-api/request/matching/uri.test.ts b/test/rest-api/request/matching/uri.test.ts
index 55a6b6525..68668c339 100644
--- a/test/rest-api/request/matching/uri.test.ts
+++ b/test/rest-api/request/matching/uri.test.ts
@@ -13,7 +13,7 @@ test('matches an exact string with the same request URL with a trailing slash',
   const res = await runtime.request('https://api.github.com/made-up/')
 
   expect(res.status()).toEqual(200)
-  expect(res.headers()).toHaveProperty('x-powered-by', 'msw')
+  expect(await res.allHeaders()).toHaveProperty('x-powered-by', 'msw')
   expect(await res.json()).toEqual({
     mocked: true,
   })
@@ -35,7 +35,7 @@ test('matches an exact string with the same request URL without a trailing slash
   const res = await runtime.request('https://api.github.com/made-up')
 
   expect(res.status()).toEqual(200)
-  expect(res.headers()).toHaveProperty('x-powered-by', 'msw')
+  expect(await res.allHeaders()).toHaveProperty('x-powered-by', 'msw')
   expect(await res.json()).toEqual({
     mocked: true,
   })
@@ -57,7 +57,7 @@ test('matches a mask against a matching request URL', async () => {
   const res = await runtime.request('https://test.mswjs.io/messages/abc-123')
 
   expect(res.status()).toEqual(200)
-  expect(res.headers()).toHaveProperty('x-powered-by', 'msw')
+  expect(await res.allHeaders()).toHaveProperty('x-powered-by', 'msw')
   expect(await res.json()).toEqual({
     messageId: 'abc-123',
   })
@@ -71,7 +71,7 @@ test('ignores query parameters when matching a mask against a matching request U
   )
 
   expect(res.status()).toEqual(200)
-  expect(res.headers()).toHaveProperty('x-powered-by', 'msw')
+  expect(await res.allHeaders()).toHaveProperty('x-powered-by', 'msw')
   expect(await res.json()).toEqual({
     messageId: 'abc-123',
   })
@@ -93,7 +93,7 @@ test('matches a RegExp against a matching request URL', async () => {
   const res = await runtime.request('https://mswjs.google.com/path')
 
   expect(res.status()).toEqual(200)
-  expect(res.headers()).toHaveProperty('x-powered-by', 'msw')
+  expect(await res.allHeaders()).toHaveProperty('x-powered-by', 'msw')
   expect(await res.json()).toEqual({
     mocked: true,
   })
@@ -115,7 +115,7 @@ test('supports escaped parentheses in the request URL', async () => {
   const res = await runtime.request(`/resource('id')`)
 
   expect(res.status()).toEqual(200)
-  expect(res.headers()).toHaveProperty('x-powered-by', 'msw')
+  expect(await res.allHeaders()).toHaveProperty('x-powered-by', 'msw')
   expect(await res.json()).toEqual({
     mocked: true,
   })
diff --git a/test/rest-api/response-patching.test.ts b/test/rest-api/response-patching.test.ts
index cfe3b3e22..33b21b58c 100644
--- a/test/rest-api/response-patching.test.ts
+++ b/test/rest-api/response-patching.test.ts
@@ -49,7 +49,7 @@ test('responds with a combination of the mocked and original responses', async (
 
   const res = await runtime.request('/user')
   const status = res.status()
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(status).toBe(200)
@@ -77,7 +77,7 @@ test('bypasses the original request when it equals the mocked request', async ()
     },
   )
   const status = res.status()
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(status).toBe(200)
@@ -127,7 +127,7 @@ test('supports patching a HEAD request', async () => {
   )
 
   const status = res.status()
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(status).toBe(200)
@@ -155,7 +155,7 @@ test('supports patching a GET request', async () => {
     },
   )
   const status = res.status()
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(status).toBe(200)
@@ -187,7 +187,7 @@ test('supports patching a POST request', async () => {
     },
   )
   const status = res.status()
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.json()
 
   expect(status).toBe(200)
diff --git a/test/rest-api/response/body/body-binary.test.ts b/test/rest-api/response/body/body-binary.test.ts
index 4e147c046..d9488bbed 100644
--- a/test/rest-api/response/body/body-binary.test.ts
+++ b/test/rest-api/response/body/body-binary.test.ts
@@ -9,7 +9,7 @@ test('responds with a given binary body', async () => {
 
   const res = await runtime.request('/images/abc-123')
   const status = res.status()
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const body = await res.body()
 
   const expectedBuffer = fs.readFileSync(
diff --git a/test/rest-api/response/body/body-json.test.ts b/test/rest-api/response/body/body-json.test.ts
index 53e9027a3..331f8d753 100644
--- a/test/rest-api/response/body/body-json.test.ts
+++ b/test/rest-api/response/body/body-json.test.ts
@@ -8,7 +8,7 @@ test('responds with a JSON response body', async () => {
 
   const res = await runtime.request('/json')
 
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   expect(headers).toHaveProperty('content-type', 'application/json')
 
   const json = await res.json()
diff --git a/test/rest-api/response/body/body-text.test.ts b/test/rest-api/response/body/body-text.test.ts
index b2fdd0013..2af0a5a55 100644
--- a/test/rest-api/response/body/body-text.test.ts
+++ b/test/rest-api/response/body/body-text.test.ts
@@ -8,7 +8,7 @@ test('responds with a text response body', async () => {
 
   const res = await runtime.request('/text')
 
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   expect(headers).toHaveProperty('content-type', 'text/plain')
 
   const text = await res.text()
diff --git a/test/rest-api/response/body/body-xml.test.ts b/test/rest-api/response/body/body-xml.test.ts
index 24732de77..295ebb12e 100644
--- a/test/rest-api/response/body/body-xml.test.ts
+++ b/test/rest-api/response/body/body-xml.test.ts
@@ -8,7 +8,7 @@ test('responds with an XML response body', async () => {
 
   const res = await request('/user')
   const status = res.status()
-  const headers = res.headers()
+  const headers = await res.allHeaders()
   const text = await res.text()
 
   expect(status).toBe(200)