-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
JUnit XML output for Continuous Integration w/ Jenkins #104
Comments
I suspect that you need to Also, in terms of debugging: The best way to do this is to run jest with |
I've made an example repo so you may debug faster the errors. https://github.com/palcu/jest-example As for debugging, I did not manage to set a single breakpoint in tests. I've installed |
Another something interesting to add to the discussion. The line in jasmine-reporters that isn't working is an attempt to use
As @palcu pointed out, the error is
What is most interesting about this is that If you switch the require order around a little bit, the problem reverses itself and the
Error: Console output:
I've never seen an error quite like this one before, and the same code works without problems when run within node directly, jasmine-node, etc. |
I've solved my first problem with debugging. I was using I now also have JUnit XML output. Here is a sample repo. The only problems I have now is that I need to explicitly unmock |
Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed. |
Please feel free to reopen this if there is anything in jest that needs to be changed to support this. |
The issue I'm having with integrating jasmine-reporters is that because Jest spawns a different jasmine instance for each file, you cannot consolidate results. Normally you would want the test suites from all tests to be aggregated into a single output but with Jest it's only possible to create an output per file |
Got this to work by adding to jest config
the problem is that i also have on my config
Notice that the reporter is included in there, it should not be in there. |
created a new issue with the above comment #1274 |
got the same problem as @megawac , DId you manage to work around that ? |
I did, I'll comment tmw (not with same library) |
The only big gotcha of using jest with jasmine xml reporters is that because tests in different files are run in different contexts you can't use considateAll. So you have to merge the results after the tests are run. jest/jasmine setup file for Junit results var jasmineReporters = require('jasmine-reporters');
var reporter = new jasmineReporters.JUnitXmlReporter({
consolidateAll: false,
savePath: process.env.JUNIT_RESULTS,
filePrefix: 'junit-'
});
jasmine.getEnv().addReporter(reporter); Merge results scripts: var fs = require('fs');
var path = require('path');
var async = require('async');
var reportMerger = require('junit-report-merger');
var results = fs.readdirSync(process.env.JUNIT_RESULTS);
let output = path.join(process.env.JUNIT_RESULTS, 'results.xml');
let files = results.map(x => path.join(process.env.JUNIT_RESULTS, x));
reportMerger.mergeFiles(output, files, {}, function() {
async.each(files, fs.unlink);
}); |
we've been working on our reporting system and now we can actually generate junit\xunit using a separate jest-reporter plugin. I think we're going to have a plugin for junit in a couple of weeks |
do you have any examples of how to write or use a jest-reporter plugin? |
@noahpeters our internal reporters are here https://github.com/facebook/jest/tree/master/packages/jest-cli/src/reporters |
any update on this for jest 15? I can't get junit xml output for the life of me! it's nice when a test fails in ci and what not. |
Any update on this beside the comment by @megawac #104 (comment) ? At the moment the missing integration with CI is a blocker to the adoption of jest in my org. |
There hasn't been any progress on this. Please feel free to send a PR to add this feature. |
@vampolo What is blocking you from using the solution you linked above? The Create a file, something like
Then just reference it in your
Also make sure to ignore that file in your |
I was able to integrate that way at the end @rsolomon. No need for the Still, this way of integrating junit output feel a bit hackish. Will try to hack a bit the jest codebase and see if i can come up with a PR. Thanks all for the help. |
@rsolomon you wouldnt happen to know of a way to only run the setup-jasmine-env (or generate junit tests) unless you're runing |
I've just got this working thanks to that very useful help by @rsolomon , thanks! @th3fallen The way I did that was to create a separate jest config file: In {
...
"setupTestFrameworkScriptFile": "./jest/setup-jasmine-env.js"
} And then specify this config file when you want junit output (e.g. in your case along with jest --config ./jest/jest-junit.json --coverage |
Also you can try this node module for junit xml output https://www.npmjs.com/package/jest-junit |
I was able to get this working with the cli option as I didn't have access to change the config. I then used |
@kellyrmilligan do you have an example? I'd like to use the new |
On the sideline here, but i ended up ditching junit format altogether and use the mocha formatting via jest-bamboo-formatter. So far it works pretty good the integration with Bamboo, but any mocha parser would work. |
create a script somewhere,
then however you're running it, something like this:
and after that is run, merge it all together:
|
@kellyrmilligan ... that helped quite a lot! But you don't need |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I have been trying to set up Jest on our Continuous Integration servers that run Jenkins. Even though Jest is built on top of Jasmine, I could not integrate it with jasmine-reporters.
I've used the branch that supports Jasmine 1.3. You can install it with
npm install jasmine-reporters@~1.0.0
.My
package.json
has:And in
setup-jasmine-env.js
I have:The error I get is
NodeJS attempt: Arguments to path.join must be strings
orNodeJS attempt: Object [object Object] has no method 'join'
. I've tried to debug it, but unfortunately you cannot set a debugger in a Jest test.Is there a way I can make Jest work on Jenkins?
The text was updated successfully, but these errors were encountered: