Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
PixnBits opened this issue May 14, 2020 · 3 comments · Fixed by #17
Closed

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

PixnBits opened this issue May 14, 2020 · 3 comments · Fixed by #17
Labels

Comments

@PixnBits
Copy link
Contributor

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

@PixnBits
Copy link
Contributor Author

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);
};

@anescobar1991
Copy link
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?

JamesSingleton pushed a commit that referenced this issue May 22, 2020
oneamexbot added a commit that referenced this issue May 26, 2020
# [6.1.0](v6.0.1...v6.1.0) (2020-05-26)

### Features

* **node:** update to work with node 14 ([#17](#17)) ([ad8663a](ad8663a)), closes [#16](#16)
@oneamexbot
Copy link
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
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants