Skip to content

Commit

Permalink
refactor: More XML in e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davidparsson committed Feb 1, 2024
1 parent 2161361 commit 84c3f96
Showing 1 changed file with 61 additions and 44 deletions.
105 changes: 61 additions & 44 deletions spec/e2e_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@ describe('JUnit Report builder', function () {

const reportWith = (content, testSuitesProperties) =>
'<?xml version="1.0" encoding="UTF-8"?>\n' +
'<testsuites ' +
parseProperties(testSuitesProperties) +
'>\n' +
content +
'\n' +
'</testsuites>';
content;

it('should produce a report identical to the expected one', function () {
builder.testCase().className('root.test.Class1');
Expand Down Expand Up @@ -83,8 +78,9 @@ describe('JUnit Report builder', function () {
expect(builder.build()).toBe(
reportWith(
// prettier-ignore
' <testsuite tests="0" failures="0" errors="0" skipped="0"/>',
{ tests: 0, failures: 0, errors: 0, skipped: 0 },
'<testsuites tests="0" failures="0" errors="0" skipped="0">\n' +
' <testsuite tests="0" failures="0" errors="0" skipped="0"/>\n' +
'</testsuites>'
),
);
});
Expand All @@ -95,8 +91,9 @@ describe('JUnit Report builder', function () {
expect(builder.build()).toBe(
reportWith(
// prettier-ignore
' <testcase/>',
{ tests: 1, failures: 0, errors: 0, skipped: 0 },
'<testsuites tests="1" failures="0" errors="0" skipped="0">\n' +
' <testcase/>\n' +
'</testsuites>'
),
);
});
Expand All @@ -107,10 +104,11 @@ describe('JUnit Report builder', function () {
expect(builder.build()).toBe(
reportWith(
// prettier-ignore
'<testsuites tests="1" failures="1" errors="0" skipped="0">\n' +
' <testcase>\n' +
' <failure message="it failed"/>\n' +
' </testcase>',
{ tests: 1, failures: 1, errors: 0, skipped: 0 },
' </testcase>\n' +
'</testsuites>'
),
);
});
Expand All @@ -121,10 +119,11 @@ describe('JUnit Report builder', function () {
expect(builder.build()).toBe(
reportWith(
// prettier-ignore
'<testsuites tests="1" failures="1" errors="0" skipped="0">\n' +
' <testcase>\n' +
' <failure message="it failed" type="the type"/>\n' +
' </testcase>',
{ tests: 1, failures: 1, errors: 0, skipped: 0 },
' </testcase>\n' +
'</testsuites>'
),
);
});
Expand All @@ -135,10 +134,11 @@ describe('JUnit Report builder', function () {
expect(builder.build()).toBe(
reportWith(
// prettier-ignore
'<testsuites tests="1" failures="0" errors="1" skipped="0">\n' +
' <testcase>\n' +
' <error message="it errored"/>\n' +
' </testcase>',
{ tests: 1, failures: 0, errors: 1, skipped: 0 },
' </testcase>\n' +
'</testsuites>'
),
);
});
Expand All @@ -149,10 +149,11 @@ describe('JUnit Report builder', function () {
expect(builder.build()).toBe(
reportWith(
// prettier-ignore
'<testsuites tests="1" failures="0" errors="1" skipped="0">\n' +
' <testcase>\n' +
' <error message="it errored" type="the type"><![CDATA[the content]]></error>\n' +
' </testcase>',
{ tests: 1, failures: 0, errors: 1, skipped: 0 },
' </testcase>\n' +
'</testsuites>'
),
);
});
Expand All @@ -163,10 +164,11 @@ describe('JUnit Report builder', function () {
expect(builder.build()).toBe(
reportWith(
// prettier-ignore
'<testsuites tests="1" failures="0" errors="0" skipped="0">\n' +
' <testsuite tests="1" failures="0" errors="0" skipped="0">\n' +
' <testcase/>\n' +
' </testsuite>',
{ tests: 1, failures: 0, errors: 0, skipped: 0 },
' </testsuite>\n' +
'</testsuites>'
),
);
});
Expand All @@ -177,12 +179,13 @@ describe('JUnit Report builder', function () {
expect(builder.build()).toBe(
reportWith(
// prettier-ignore
'<testsuites tests="1" failures="1" errors="0" skipped="0">\n' +
' <testsuite tests="1" failures="1" errors="0" skipped="0">\n' +
' <testcase>\n' +
' <failure/>\n' +
' </testcase>\n' +
' </testsuite>',
{ tests: 1, failures: 1, errors: 0, skipped: 0 },
' </testsuite>\n' +
'</testsuites>'
),
);
});
Expand All @@ -193,12 +196,13 @@ describe('JUnit Report builder', function () {
expect(builder.build()).toBe(
reportWith(
// prettier-ignore
'<testsuites tests="1" failures="0" errors="1" skipped="0">\n' +
' <testsuite tests="1" failures="0" errors="1" skipped="0">\n' +
' <testcase>\n' +
' <error/>\n' +
' </testcase>\n' +
' </testsuite>',
{ tests: 1, failures: 0, errors: 1, skipped: 0 },
' </testsuite>\n' +
'</testsuites>'
),
);
});
Expand All @@ -209,12 +213,13 @@ describe('JUnit Report builder', function () {
expect(builder.build()).toBe(
reportWith(
// prettier-ignore
'<testsuites tests="1" failures="0" errors="0" skipped="1">\n' +
' <testsuite tests="1" failures="0" errors="0" skipped="1">\n' +
' <testcase>\n' +
' <skipped/>\n' +
' </testcase>\n' +
' </testsuite>',
{ tests: 1, failures: 0, errors: 0, skipped: 1 },
' </testsuite>\n' +
'</testsuites>'
),
);
});
Expand All @@ -225,7 +230,9 @@ describe('JUnit Report builder', function () {
expect(builder.build()).toBe(
reportWith(
// prettier-ignore
' <testsuite time="2.5" tests="0" failures="0" errors="0" skipped="0"/>',
'<testsuites tests="0" failures="0" errors="0" skipped="0">\n' +
' <testsuite time="2.5" tests="0" failures="0" errors="0" skipped="0"/>\n' +
'</testsuites>'
),
);
});
Expand All @@ -236,7 +243,9 @@ describe('JUnit Report builder', function () {
expect(builder.build()).toBe(
reportWith(
// prettier-ignore
' <testsuite timestamp="2015-11-22T13:37:59" tests="0" failures="0" errors="0" skipped="0"/>',
'<testsuites tests="0" failures="0" errors="0" skipped="0">\n' +
' <testsuite timestamp="2015-11-22T13:37:59" tests="0" failures="0" errors="0" skipped="0"/>\n' +
'</testsuites>'
),
);
});
Expand All @@ -247,10 +256,11 @@ describe('JUnit Report builder', function () {
expect(builder.build()).toBe(
reportWith(
// prettier-ignore
'<testsuites tests="1" failures="0" errors="0" skipped="0">\n' +
' <testsuite tests="1" failures="0" errors="0" skipped="0">\n' +
' <testcase time="2.5"/>\n' +
' </testsuite>',
{ tests: 1, failures: 0, errors: 0, skipped: 0 },
' </testsuite>\n' +
'</testsuites>'
),
);
});
Expand All @@ -261,12 +271,13 @@ describe('JUnit Report builder', function () {
expect(builder.build()).toBe(
reportWith(
// prettier-ignore
'<testsuites tests="1" failures="0" errors="0" skipped="0">\n' +
' <testsuite tests="1" failures="0" errors="0" skipped="0">\n' +
' <testcase>\n' +
' <system-out><![CDATA[This was written to stdout!]]></system-out>\n' +
' </testcase>\n' +
' </testsuite>',
{ tests: 1, failures: 0, errors: 0, skipped: 0 },
' </testsuite>\n' +
'</testsuites>'
),
);
});
Expand All @@ -277,12 +288,13 @@ describe('JUnit Report builder', function () {
expect(builder.build()).toBe(
reportWith(
// prettier-ignore
'<testsuites tests="1" failures="0" errors="0" skipped="0">\n' +
' <testsuite tests="1" failures="0" errors="0" skipped="0">\n' +
' <testcase>\n' +
' <system-err><![CDATA[This was written to stderr!]]></system-err>\n' +
' </testcase>\n' +
' </testsuite>',
{ tests: 1, failures: 0, errors: 0, skipped: 0 },
' </testsuite>\n' +
'</testsuites>'
),
);
});
Expand All @@ -297,15 +309,16 @@ describe('JUnit Report builder', function () {
expect(builder.build()).toBe(
reportWith(
// prettier-ignore
'<testsuites tests="1" failures="0" errors="0" skipped="0">\n' +
' <testsuite tests="1" failures="0" errors="0" skipped="0">\n' +
' <testcase>\n' +
' <system-err>\n' +
' <![CDATA[This was written to stderr!]]>\n' +
' [[ATTACHMENT|absolute/path/to/attachment]]\n' +
' </system-err>\n' +
' </testcase>\n' +
' </testsuite>',
{ tests: 1, failures: 0, errors: 0, skipped: 0 },
' </testsuite>\n' +
'</testsuites>'
),
);
});
Expand All @@ -318,10 +331,11 @@ describe('JUnit Report builder', function () {
expect(builder.build()).toBe(
reportWith(
// prettier-ignore
'<testsuites tests="2" failures="0" errors="0" skipped="0">\n' +
' <testcase name="1"/>\n' +
' <testsuite name="2" tests="0" failures="0" errors="0" skipped="0"/>\n' +
' <testcase name="3"/>',
{ tests: 2, failures: 0, errors: 0, skipped: 0 },
' <testcase name="3"/>\n' +
'</testsuites>'
),
);
});
Expand All @@ -332,10 +346,11 @@ describe('JUnit Report builder', function () {
expect(builder.build()).toBe(
reportWith(
// prettier-ignore
'<testsuites tests="1" failures="0" errors="0" skipped="0">\n' +
' <testcase>\n' +
' <system-out><![CDATA[Emoji: 🤦]]></system-out>\n' +
' </testcase>',
{ tests: 1, failures: 0, errors: 0, skipped: 0 },
' </testcase>\n' +
'</testsuites>'
),
);
});
Expand All @@ -346,10 +361,11 @@ describe('JUnit Report builder', function () {
expect(builder.build()).toBe(
reportWith(
// prettier-ignore
'<testsuites tests="1" failures="0" errors="1" skipped="0">\n' +
' <testcase>\n' +
' <error message="it is &quot;quoted&quot;"/>\n' +
' </testcase>',
{ tests: 1, failures: 0, errors: 1, skipped: 0 },
' </testcase>\n' +
'</testsuites>'
),
);
});
Expand All @@ -360,10 +376,11 @@ describe('JUnit Report builder', function () {
expect(builder.build()).toBe(
reportWith(
// prettier-ignore
'<testsuites tests="1" failures="0" errors="1" skipped="0">\n' +
' <testcase>\n' +
' <error message="InvalidCharactersStripped"/>\n' +
' </testcase>',
{ tests: 1, failures: 0, errors: 1, skipped: 0 },
' </testcase>\n' +
'</testsuites>'
),
);
});
Expand Down

0 comments on commit 84c3f96

Please sign in to comment.