practicalmeteor / meteor-mocha-xunit-reporter

1 stars 2 forks source link

Xunit in xml format. #1

Open mfpinheiro opened 8 years ago

mfpinheiro commented 8 years ago

Hey

I use this package to export a report , but i only see the result on the browser console. How can i exporte the result text to xunit file ou xml file ? Thanks.

jsep commented 8 years ago

Hello @mfpinheiro, here is how you can export a xml file

spacejam test --driver-package=practicalmeteor:mocha-xunit-reporter --xunit-out file.xml

Make sure you are using the latest releases of the packages.

Let me know if its working for you :smile:

mfpinheiro commented 8 years ago

Hey @jsep, thank you for the response.

So i never use this before, so a i'm a bit confused. I try running, with the spacejam test --driver-package=practicalmeteor:mocha-xunit-reporter --xunit-out file.xml And now got the error:

spacejam test --driver-package=practicalmeteor:mocha-xunit-reporter --xunit-out file.xml
spacejam: spawning meteor
[[[[[ Tests ]]]]]

=> Started proxy.
=> Started MongoDB.
spacejam: meteor mongodb is ready
=> Started your app.

=> App running at: http://localhost:4096/
spacejam: meteor is ready
spacejam: spawning phantomjs
phantomjs: Running tests at http://localhost:4096/xunit using test-in-console
------------------------------------------------
----------------PACKAGE VERSIONS----------------
practicalmeteor:mocha: 2.4.5_5
practicalmeteor:mocha-console-runner: 0.2.2
practicalmeteor:mocha-xunit-reporter: 0.1.0
------------------------------------------------
------------------------------------------------
phantomjs: There is no route for the path: /xunit
    http://localhost:4096/packages/kadira_flow-router.js?hash=09ea12875d3801955ee70797bf8e4a70feebc570: 519
spacejam: phantomjs exited with code: 6
spacejam: killing meteor
spacejam: meteor killed with signal: SIGTERM
spacejam: Unhandled error in meteor client side code. Exiting.

I'm searching for something similar, but if you know about this, please explain for me. Thanks :)

jsep commented 8 years ago

Hello @mfpinheiro It seems to be kadira:flow-router its making spacejam to fail,

What you can do is declare a route with flow-router that do nothing:

FlowRouter.route('/xunit', {
    action: function(params, queryParams) {
        console.log("XUnit reporter");
    }
});
mfpinheiro commented 8 years ago

Hi @jsep, unfortunately this don't work. I wondering if, there's any way, to make Kadria_flow-route ignore this route, and continue the process. What you think about that ? A update you project, for the lastest version of meteor, and no conflicts :)

mfpinheiro commented 8 years ago

Hi @jspe , Great news. Finally works. I make two empty files in my folder for public templates tests.js and tests.html, and i import this tests.js in my public route.js Heres is the code of the my public routes:

route.js

import { FlowRouter } from 'meteor/kadira:flow-router';

import '../../../ui/public/tests.js';

const publicRedirect = (context, redirect) => {
  if (Meteor.userId()) {
    redirect('index');
  }
};

const tests = FlowRouter.group({
    name: 'xunit',
    triggersEnter: [publicRedirect],
});

tests.route('/xunit', {
  name: 'xunit',
  triggersEnter: [publicRedirect],
});

To run i use

spacejam test --driver-package=practicalmeteor:mocha-xunit-reporter --xunit-out file.xml

And now he created this file.xml in the root direct of the project. Thanks a lot for your support @jsep . If i discovered more, about this error or a better way to handle with this i share in here.

o /

thebarty commented 7 years ago

This feels really hacky, but thanks for the code!

OK, I am one step ahead, BUT now I am getting an error: Potentially incompatible change required to top-level dependency: practicalmeteor:mocha 2.4.5_5, was 2.4.5_6 when trying to install practicalmeteor:mocha-xunit-reporter

mfpinheiro commented 7 years ago

@thebarty Hey man, sorry for the late response. In a recent project a friend my used https://github.com/practicalmeteor/spacejam and to out a xunit file The command line options to pass to phantomjs. The default is --load-images=no --ssl-protocol=TLSv1. --xunit-out

after the commands of spacejam.

in their website, have a lot examples.

hope this help you. o /

thebarty commented 7 years ago

@mfpinheiro Thanks a lot for your help, buddy! I should have looked at those spacejam docs a lot earlier! 👍 OK, lets see if I get it running!

thebarty commented 7 years ago

@mfpinheiro: YEAH MAN!! After wasting days and hours I am finally seeing an XML. You saved my day!!!

@jsep : This should be in the docs!!!! Really really really!!!

// this is how it works
spacejam test --driver-package=practicalmeteor:mocha-xunit-reporter --load-images=no --ssl-protocol=TLSv1 --xunit-out ./unit-integrational-results.xml --port 7357
thebarty commented 7 years ago

https://forums.meteor.com/t/how-to-run-mocha-unit-tests-on-circleci-and-output-xml/35108

mfpinheiro commented 7 years ago

@thebarty Hey brother. I really glad that those things work out. I have a really hard time with this.
My friend @lucasmonteiro001 managed to get things done recently :D

thebarty commented 7 years ago

@mfpinheiro : Hey ho! Yeah same over here. Getting the first xml output took me like 2 workdays.

OH DAMN!! I am still NOT done: on CircleCi spacejam runs sooo long, that it times out after 2 hours.

The integrational-tests run around 10 minutes on my osx using dispatch:mocha. When I run them locally osx using spacejam they take 1 hours. On CircleCi they take 2+ hours and hit the 2 hour timeoff limit.

I guess it has to do with phantomjs that those tests run sooo slow using spacejam.

Damn!!

Any other ideas??

mfpinheiro commented 7 years ago

@thebarty hey dude! Unfortunately i never used CircleCi. One thing i can think of is about meteor test full app command, because there's a difference in between meteor simple test and full app test. But not sure if this is a issue. Sorry for not helping this time.