Skip to content
This repository has been archived by the owner on Dec 18, 2019. It is now read-only.

use fullTitle of a suite in reporter #79

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

sherlock1982
Copy link

@sherlock1982 sherlock1982 commented Dec 4, 2017

I have some nested describes in mocha and in junit reporter they look ugly because reporter takes name of inner describe only.
Here's suggested patch to take fullTitle of a suite so in report it will look nicer.
We can make it optional if you want no to break anything.

@christian-bromann
Copy link
Contributor

christian-bromann commented Dec 4, 2017

they look ugly

Can you provide a screenshot of how the logs look before and after?

@sherlock1982
Copy link
Author

I have two specs now:

describe('PBX', () => {
    describe('Validations', () => {
        it('should validate something important', () => {

        })
    })

    describe('Editor', () => {
        it('should edit something important', () => {

        })
    })
})
describe('Settings', () => {
    describe('Validations', () => {
        it('should validate something important', () => {

        })
    })

    describe('Editor', () => {
        it('should edit something important', () => {

        })
    })
})

This is before:

image

This is after:

image

})

this.on('suite:start', function (suite) {
this.suitTitles[suite.cid][suite.uid] = suite.fullTitle
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is only available in Mocha, how do we deal with this if someone uses a different framework?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I hadn't thought about it. At least 'parent' attribute is available in Jasmine and Mocha so I can join fullTitle directly in this function. Let me extend it.
Also seems that parent suite always starts before. So I can suggest by the time child suite will start I will already have a name for parent.

@christian-bromann
Copy link
Contributor

@sherlock1982 any updates?

@christian-bromann
Copy link
Contributor

ping @sherlock1982

@dbashford
Copy link

FWIW, I've just got this copied into our codebase as we need it. Can hopefully get this work incorporated at some point.

@arstanton
Copy link

Any progress with this? As it is now, it's encouraged only using one describe block (because only the inner most block is visible), which makes it harder to include beforeEach(), afterEach(), etc..., hooks.

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

Successfully merging this pull request may close these issues.

4 participants