title: Testing Headers of Axios Request
body: <p>I'm using Mocha + Chai and <a href="https://github.com/ctimmerm/axios-mock-adapter" rel="noreferrer">axios-mock-adapter</a> for testing my axios request. It workes well, but I don't know how to <code>test headers</code> of axios by axios-mock-adapter and make sure <code>Authorization</code> and <code>Content-type</code> is correct!</p>
  
  <pre><code>export const uploadFile = (token: string, fileName: string, file: Buffer): Promise&lt;string&gt; =&gt; {
    return new Promise((resolve, reject): void =&gt; {
      const uploadFileURL = `xxxxx.com`;
      axios
        .put(uploadFileURL, file, {
          headers: {
            Authorization: `Bearer ${token}`,
            "Content-type": "application/x-www-form-urlencoded",
          },
        })
        .then((response): void =&gt; {
          resolve(response.data.id);
        })
        .catch((error: Error): void =&gt; {
          reject(error.message);
        });
    });
  };
  </code></pre>
  
  <p>And this is my test function</p>
  
  <pre><code>  describe("uploadFile", (): void =&gt; {
      let mockAxios: MockAdapter;
      beforeEach((): void =&gt; {
        mockAxios = new MockAdapter(axios);
      });
  
      afterEach((): void =&gt; {
        mockAxios.reset();
      });
  
      it("should return item's id", (done): void =&gt; {
        const fileName: string = faker.system.fileName();
        const token: string = faker.random.words();
        const file: Buffer = Buffer.from(faker.random.words());
        const expectedResult = {
          id: faker.random.uuid(),
        };
        mockAxios.onPut(`xxxxx.com`).reply(200, expectedResult, {
          Authorization: `Bearer ${token}`,
          "Content-type": "application/x-www-form-urlencoded",
        });
  
        uploadFile(token, fileName, file)
          .then((actualResult: string): void =&gt; {
            // I want to test my header of my requests
            expect(actualResult).to.equal(expectedResult.id);
            done(); // done make sure we know when we run the test
          })
          .catch(done);
      });
    });
  </code></pre>
  
  <p>So if anyone know how to write correct test for the header request, please help me. Thanks in advance!</p>