I'd suggest adding a static csv file to src/mocks instead of trying to generate it manually.
In the mock service worker you'll most likely want to use binary response type https://mswjs.io/docs/recipes/binary-response-type You'd also need to add header for the response to be handled correctly by the browser, e.g.: ctx.set('Content-Type', 'text/csv') ctx.set('Content-Disposition', 'attachment; filename="tokens.csv') -- https://code.launchpad.net/~jonesogolo/maas-site-manager/+git/maas-site-manager/+merge/442741 Your team MAAS Committers is requested to review the proposed merge of ~jonesogolo/maas-site-manager:1548-enrolment-tokens-export-action into maas-site-manager:main. -- Mailing list: https://launchpad.net/~sts-sponsors Post to : sts-sponsors@lists.launchpad.net Unsubscribe : https://launchpad.net/~sts-sponsors More help : https://help.launchpad.net/ListHelp