Skip to content

Question: how to mock with jest #450

Description

@vahidvdn

Although this is for tracing bugs, since my question is specific to csv-parser I thought maybe it's the right place to ask. (hope you don't mind)

I have the following code to parse csv files:

const records = [];
const parser = fs
  .createReadStream(`${process.cwd()}/${file.destination}/${file.filename}`)
  .pipe(parse({}));

for await (const record of parser) {
  records.push(record);
}

I wanted to know how to mock this code in unit tests with jest. Any idea would be appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions