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

How to make xunit reporter avoid encode test messages. #3586

Closed
4 tasks done
ybbpgfjtey opened this issue Nov 29, 2018 · 1 comment
Closed
4 tasks done

How to make xunit reporter avoid encode test messages. #3586

ybbpgfjtey opened this issue Nov 29, 2018 · 1 comment
Labels
area: reporters involving a specific reporter type: question support question

Comments

@ybbpgfjtey
Copy link

ybbpgfjtey commented Nov 29, 2018

Prerequisites

  • Checked that your issue hasn't already been filed by cross-referencing issues with the faq label
  • Checked next-gen ES issues and syntax problems by using the same environment and/or transpiler configuration without Mocha to ensure it isn't just a feature that actually isn't supported in the environment in question or a bug in your code.
  • 'Smoke tested' the code to be tested by running it outside the real test suite to get a better sense of whether the problem is in the code under test, your usage of Mocha, or Mocha itself
  • Ensured that there is no discrepancy between the locally and globally installed versions of Mocha. You can find them with: node node_modules/.bin/mocha --version(Local) and mocha --version(Global). We recommend avoiding the use of globally installed Mocha.

Description

The xunit reporter always encodes everything, but if there's some Chinese characters, the report file will
generate something like this:

<testsuite name="Mocha Tests" tests="1" failures="1" errors="1" skipped="0" timestamp="Thu, 29 Nov 2018 03:23:34 GMT" time="0.035">
<testcase classname="&#x767E;&#x5EA6;" name="&#x9996;&#x9875;" time="0.003"><failure>expected &#x27;&#x6D4B;&#x8BD5;&#x27; to equal &#x27;&#x9519;&#x8BEF;&#x27;
AssertionError: expected &#x27;&#x6D4B;&#x8BD5;&#x27; to equal &#x27;&#x9519;&#x8BEF;&#x27;
    at Context.&#x3C;anonymous&#x3E; (C:/Users/ybbpg/Desktop/node-test/test/test.js:10:17)</failure></testcase>
</testsuite>

Totally unreadable, is there any way to avoid this?

Steps to Reproduce

  1. Make test.js file:
import "chai/register-should";

describe("中文测试", function () {
  it("测试", () => {
    "测试".should.equal("测试 Not Equal"); // Will get error
  });
});
  1. run mocha using.
mocha --require babel-core/register --reporter=xunit --reporter-options output=report/jUnit.xml test.js
  1. check report/jUnit.xml.

Expected behavior: [What you expect to happen]
Don't encode classname, name, and body of testcase.

<testsuite name="Mocha Tests" tests="1" failures="1" errors="1" skipped="0" timestamp="Thu, 29 Nov 2018 03:25:19 GMT" time="0.039">
<testcase classname="中文测试" name="测试" time="0.004"><failure>expected 测试  to equal 测试 Not Equal
AssertionError: expected 测试 to equal 测试 Not Equal 
    at Context.&#x3C;anonymous&#x3E; (C:/Users/ybbpg/Desktop/node-test/test/test.js:10:17)</failure></testcase>
</testsuite>

Actual behavior: [What actually happens]
Encode everything.

<testsuite name="Mocha Tests" tests="1" failures="1" errors="1" skipped="0" timestamp="Thu, 29 Nov 2018 03:25:19 GMT" time="0.039">
<testcase classname="&#x4E2D;&#x6587;&#x6D4B;&#x8BD5;" name="&#x6D4B;&#x8BD5;" time="0.004"><failure>expected &#x27;&#x6D4B;&#x8BD5;&#x27; to equal &#x27;&#x6D4B;&#x8BD5; Not Equal&#x27;
AssertionError: expected &#x27;&#x6D4B;&#x8BD5;&#x27; to equal &#x27;&#x6D4B;&#x8BD5; Not Equal&#x27;
    at Context.&#x3C;anonymous&#x3E; (C:/Users/ybbpg/Desktop/node-test/test/test.js:10:17)</failure></testcase>
</testsuite>

Reproduces how often: 100%

Versions

  • The output of mocha --version and node node_modules/.bin/mocha --version: 5.2.0
  • The output of node --version: v10.12.0
  • The version and architecture of your operating system: win 10
  • Your shell (bash, zsh, PowerShell, cmd, etc.): PowerShell
  • Your browser and version (if running browser tests): chrome
  • Any other third party Mocha related modules (with versions): chai 4.2.0
  • The code transpiler being used: babel 6.26.0
@JoshuaKGoldberg
Copy link
Member

This open question has existed for quite a while without a concrete answer. Per #5027 we've moved question-asking to Discord. If you're reading this and interested, please:

  1. Search other issues for what you're trying to do
  2. Ask there or StackOverflow

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: reporters involving a specific reporter type: question support question
Projects
None yet
Development

No branches or pull requests

3 participants