Skip to content

unable to write HTML report in Node.JS 14.x #16

Closed

Description

@PixnBits

All tests run, but on completion an error is thrown:

Ran all test suites.
TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received an instance of XMLElement
    at Object.writeFileSync (fs.js:1380:5)
    at writeFile (.../node_modules/amex-jest-preset/html-report-creator.js:26:6)

I believe this is due to a breaking change in Node.JS 14.x where data is no longer being coerced nodejs/node#31030

Activity

  1. PixnBits commented on May 14, 2020

    @PixnBits
    ContributorAuthor

    fixing this is as easy as adding .toString() to htmlOutput
    https://github.com/americanexpress/amex-jest-preset/blob/master/html-report-creator.js#L95

    writeFile(process.env.JEST_TEST_REPORT_PATH || path.join(process.cwd(), 'test-results/test-report.html'), htmlOutput.toString());

    but I wonder if, especialy for large test suites, memory could be conserved by streaming instead
    https://github.com/oozcitak/xmlbuilder-js/wiki#xml-writers
    Is there any reason fs.writeFileSync was used? (Does jest require synchronous behavior?)

    const writeFile = (filePath, content) => {
    mkdirp.sync(path.dirname(filePath));
    fs.writeFileSync(filePath, content);
    };

  2. anescobar1991 commented on May 15, 2020

    @anescobar1991
    Member

    Yes https://jestjs.io/docs/en/configuration.html#testresultsprocessor-string must be synchronous unfortunately.

    @PixnBits would you mind opening a PR to fix this?

  3. added a commit that references this issue on May 22, 2020
    ad8663a
  4. added a commit that references this issue on May 26, 2020
  5. oneamexbot commented on May 26, 2020

    @oneamexbot
    Contributor

    🎉 This issue has been resolved in version 6.1.0 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions