microsoft/playwright-test

Junit.xml Reporter Characters

BillyBolton opened this issue · 4 comments

I noticed an issue with the junit reporter character encoding when used with playwright-axe. The issue seems to be exclusive to junit reporter, as opposed to perfect output from the line reporter.

Line Reporter Test Result Output:
xml-export

In the xml file though, the encoding is different:
xml terminal

CircleCi can't parse due to this:
circle

Is this normal behavior? I've been looking at the modules for far too long.

I'm still getting the same issue. @dgozman Can this be re-opened?

<testsuite name="tests/foo.spec.ts" timestamp="1618404293678" hostname="" tests="3" failures="3" skipped="0" time="16.142" errors="0">
<testcase name="is a basic test with the page" classname="tests/foo.spec.ts " time="7.535">
<failure message="foo.spec.ts:3:1 is a basic test with the page" type="FAILURE">
  tests/foo.spec.ts:3:1 › [chromium] is a basic test with the page =================================

    Error: expect(received).toBe(expected) // Object.is equality

    Expected: &amp;quot;2&amp;quot;
    Received: &amp;quot;Playwright&amp;quot;

      4 |     await page.goto(&amp;quot;https://playwright.dev/&amp;quot;);
      5 |     const name = await page.innerText(&amp;quot;.navbar__title&amp;quot;);
    &gt; 6 |     expect(name).toBe(&amp;quot;2&amp;quot;);
        |                  ^
      7 | });

        at Spec.fn (/home/user/Desktop/dev/tdd-playwright-example/e3e/tests/foo.spec.ts:6:18)
        at WorkerRunner._runTestWithBeforeHooks (/home/user/Desktop/dev/tdd-playwright-example/e3e/node_modules/folio/out/workerRunner.js:299:13 ``` 

Here is my config file based on the new documentation:

import { ChromiumEnv, FirefoxEnv, WebKitEnv, test, setConfig } from "@playwright/test";
import { reporters, setReporters } from "@playwright/test";

setConfig({
    testDir: __dirname,  // Search for tests in this directory.
    timeout: 30000,  // Each test is given 30 seconds.
    // timeout: 90000,  // Each test is given 90 seconds.
    retries: 0,  // Failing tests will be retried at most two times.
});

setReporters([
    // Report to the terminal with "line" reporter.
    new reporters.line(),
    // Additionally, output a JUnit XML file.
    new reporters.junit({ outputFile: 'junit.xml', stripANSIControlSequences: true }),
]);

const options = {
    // Launch options:
    headless: true,
    slowMo: 50,
    // Context options:
    viewport: { width: 800, height: 600 },
    ignoreHTTPSErrors: true,
    // Testing options:
    // video: 'retain-on-failure',
    screenshot: 'only-on-failure'
};

// Run tests in three browsers.
test.runWith(new ChromiumEnv(options), { tag: 'chromium' });
test.runWith(new FirefoxEnv(options), { tag: 'firefox' });
test.runWith(new WebKitEnv(options), { tag: 'webkit' });```

@BillyBolton What is the problem in the example you pasted? You don't like &amp; escapes? Unfortunately, we'll have to escape at least some characters, e.g. <, otherwise it won't be a valid xml file.

@dgozman Thanks for getting back to me. Yea the &amp, &quote, &gt aren't playing well. Comparing the line and junit reporters seem to conclude that it's related to ANSI formatting. I try using the new config option, stripANSIControlSequences: true, but it doesn't seem to make a difference.