This is obviously a simplified test but if this works I'm able to do mine.
I want to create a file with string code
and download the txt file.
The txt file should have bla bla bla
$("button[id^='downloadTestCase-']").click(function() {
var code = "bla bla bla"
var file = new Blob([code], {
type: 'text/plain'
});
window.open(URL.createObjectURL(file));
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button type="button" class="btn btn-rounded btn-danger-outline" id="downloadTestCase-Teste50" name="Teste50">Download</button>