Browse Source

[reporter] xUnit reporter fix for skipped tests

master
Muthu Kumar 6 years ago
parent
commit
190dd1e223
  1. 3
      .vscode/launch.json
  2. 2
      package.json
  3. 21
      sample/sample7.test.js
  4. 11
      src/reporters/xunit.js

3
.vscode/launch.json

@ -8,7 +8,8 @@
"type": "node",
"request": "launch",
"name": "Debug Gunner",
"program": "${workspaceFolder}/sample/sample.test.js",
"runtimeExecutable": "/home/mkr/.nvs/node/10.8.0/x64/bin/node",
"program": "${workspaceFolder}/sample/sample7.test.js",
"args": [
"--log",
"--trace",

2
package.json

@ -1,6 +1,6 @@
{
"name": "@klenty/gunner",
"version": "0.11.6",
"version": "0.11.7",
"description": "Zero magic, fast test-runner and assertion framework. No magic globals.",
"main": "index.js",
"repository": {

21
sample/sample7.test.js

@ -3,7 +3,7 @@
* used during development
*/
const Gunner = require('../es5/Gunner');
const Gunner = require('../src/Gunner');
const expect = Gunner.expect;
const expectMany = Gunner.expectMany;
const gunner = new Gunner('sample tests');
@ -37,17 +37,10 @@ gunner.test('wait and resolve', () => {
gunner.test('should resolve to 5', () =>
expect(Promise.resolve(5)).resolvesTo(5));
// gunner.before(
// 'file must have hello as content',
// () => console.log('>> starting test! file must have hello as content'),
// 'helloContentBefore',
// );
// gunner.after(
// 'file must have hello as content',
// () => console.log('>> finished test! file must have hello as content'),
// 'helloContentAfter',
// );
gunner.before(
'file must have hello as content',
() => { throw new Error('>> I caused a before hook to fail!') }
);
gunner.test('file must have hello as content', async () => {
const { readFile } = require('fs').promises;
@ -99,5 +92,5 @@ gunner.test('(should fail) should not resolve to 5', () =>
const trace = process.argv.slice(2).indexOf('--trace') !== -1;
const reporter = process.argv.slice(2).indexOf('--log') !== -1;
gunner.run({ trace, reporter });
// gunner.run({ reporter:'xunit' });
// gunner.run({ trace, reporter });
gunner.run({ reporter:'xunit' });

11
src/reporters/xunit.js

@ -20,14 +20,11 @@ const toJSON = resultsArray => {
time: (results.duration / 1000) || 0,
},
children: results.reduce((acc, r) => {
const reason = r.reason ? (r.reason.stack || r.reason) : '';
const content = r.status !== 'ok' &&
(r.status === 'skip'
? 'skipped'
: {
name: 'failure',
text: r.reason
? (r.reason && r.reason.stack) : ''
});
r.status === 'skip'
? { name: 'skipped', text: reason }
: { name: 'failure', text: reason };
acc.push({
name: 'testcase',
attrs: {

Loading…
Cancel
Save