Skip to content
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

Custom reporter for jasmine via jasmine-browser-runner? #40

Closed
bksglatz opened this issue Sep 1, 2023 · 6 comments
Closed

Custom reporter for jasmine via jasmine-browser-runner? #40

bksglatz opened this issue Sep 1, 2023 · 6 comments

Comments

@bksglatz
Copy link

bksglatz commented Sep 1, 2023

Is there any way to get custom reporter for jasmine (like https://www.npmjs.com/package/jasmine-reporters) configured to be used with jasmine-browser-runner.

@sgravrock
Copy link
Member

sgravrock commented Sep 1, 2023

Yes. You can add it to the reporters array in your config file. With most reporters you can just specify the name of the module that exports the reporter constructor, but jasmine-reporters is more complex so you need to use a JS (not JSON) config file and do something like this:

// spec/support/jasmine-browser.js

const jasmineReporters = require('jasmine-reporters');
const junitReporter = new jasmineReporters.JUnitXmlReporter({
    // ...reporter configuration snipped...
});

module.exports = {
  reporters: [ junitReporter ],
  // ...other config properties snipped...
};

Depending on what the reporter you're using does, you might also want to set useConsoleReporter to false.

@bksglatz
Copy link
Author

bksglatz commented Sep 1, 2023

Im fine with using a ts/js file instead of a json file for configuration. I was Can i just forward the path to the js file as i do it for the json file via the same parameter when running jasmine-browser-runner?

Maybe consider extending the documentation. I wasn't able to find any information about how to add custom reporters or use a js configuration instead of json configuration or a list of all supported configuration values except those from the example file created during init.

Thx for the fast response and help. I will let you know if i was able to get it running this way.

@bksglatz
Copy link
Author

bksglatz commented Sep 1, 2023

Okay... Forget what i have written about the documentation. I wasn't able to find it ;) My fault... Everyting there: https://jasmine.github.io/api/browser-runner/edge/Configuration.html

@HolgerJeromin
Copy link
Contributor

@bksglatz
Copy link
Author

bksglatz commented Sep 1, 2023

Loading the reporter this way works fine. However the reporter does not work anymore or not the way i want it to work. But now that i know how to load reporters i can write my own :)

@sgravrock
Copy link
Member

I'm glad that worked.

There's some discussion about the structure and discoverability of config docs at jasmine/jasmine.github.io#161 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants