F
F
Frisby
Search…
File Uploads
Since Frisby.js is based on the Fetch API, file uploads are a cinch with the built-in FormData object (see Using FormData Objects on MDN if you are not familiar with them).
You can get a new FormData object from Frisby:
1
let formData = frisby.formData();
Copied!
A full usage example might look like this:
1
const csvPath = path.resolve(__dirname, './file.csv');
2
let content = fs.createReadStream(csvPath);
3
let formData = frisby.formData();
4
5
formData.append('file', content);
6
7
return frisby
8
.post('http://api.example.com/files', { body: formData })
9
.inspectRequestHeaders()
10
.expect('status', 200)
Copied!
Last modified 1yr ago
Copy link