Frisby
  • Introduction
  • Introduction
    • Frisby.js Overview
    • Getting Started
  • API and Usage
    • HTTP Request Methods
    • globalSetup() / setup()
    • Running Assertions
    • Nested Tests
    • Inspectors
    • File Uploads
Powered by GitBook
On this page

Was this helpful?

  1. API and Usage

File Uploads

PreviousInspectors

Last updated 5 years ago

Was this helpful?

Since Frisby.js is based on the Fetch API, file uploads are a cinch with the built-in FormData object (see if you are not familiar with them).

You can get a new FormData object from Frisby:

let formData = frisby.formData();

A full usage example might look like this:

const csvPath = path.resolve(__dirname, './file.csv');
let content = fs.createReadStream(csvPath);
let formData = frisby.formData();

formData.append('file', content);

return frisby
  .post('http://api.example.com/files', { body: formData })
  .inspectRequestHeaders()
  .expect('status', 200)
Using FormData Objects on MDN