You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Gist to test the content of an Excel File in a controller (e2e) test, with a lib like supertest:
functionbinaryParser(res,callback){res.setEncoding('binary')res.data=''res.on('data',function(chunk){res.data+=chunk})res.on('end',function(){callback(null,newBuffer(res.data,'binary'))})}describe('exports/:id (GET)',()=>{it('should return an excel File',async()=>{constres=awaitrequest(app.getHttpServer()).get('/exports/xxx').expect('Content-Type','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=utf-8').buffer().parse(binaryParser)assert.ok(Buffer.isBuffer(res.body))constworkbook=XLSX.read(res.body,{type: 'buffer'})constsheet=workbook.Sheets[workbook.SheetNames[0]]constjson=XLSX.utils.sheet_to_json(sheet,{header: 1})expect(json).toEqual([['My first Row','My second Row'],['val 1',50],['val 2',10]])})})
The text was updated successfully, but these errors were encountered:
Very cool, thanks for sharing! Server demos like the express example currently recommend opening the page with a browser (or using curl to upload data manually)
Is there a reason why the content type is text/xlsx rather than the typical application/vnd.ms-excel or application/vnd.openxmlformats-officedocument.spreadsheetml.sheet ?
Gist to test the content of an Excel File in a controller (e2e) test, with a lib like supertest:
The text was updated successfully, but these errors were encountered: