Assertion on 'finish' of a Writeable stream #2872
-
Maybe I don't understand writeable streams, but I can't get this to pass.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Your question is about JavaScript, not AVA specifically. The async test function will finish as soon as all the const test = require("ava");
const fs = require("fs");
const {pipeline: streamPipeline} = require('stream/promises');
const invoice = require("./invoice_payload.json");
test("Make Invoice PDF", async (t) => {
// Creates a Readable stream
const invoiceFile = await fillInvoice(invoice[0]);
const output = fs.createWriteStream("test/filledInvoice.pdf");
await streamPipeline(invoiceFile, output);
}); |
Beta Was this translation helpful? Give feedback.
Your question is about JavaScript, not AVA specifically. The async test function will finish as soon as all the
await
's are resolved and the following synchronous code executed. The.on
handler will never have time to fire. Instead of using.pipe
, usestream.pipeline
. Something like this: