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

Setting message (reason) for test skip #2572

Closed
ponmudivn opened this issue Nov 3, 2016 · 9 comments
Closed

Setting message (reason) for test skip #2572

ponmudivn opened this issue Nov 3, 2016 · 9 comments
Labels
area: usability concerning user experience or interface type: feature enhancement proposal

Comments

@ponmudivn
Copy link

ponmudivn commented Nov 3, 2016

Is it possible to set a message (mentioning reason) why a particular test is skipped, so that it could be used in reporters.

describe('xxx', function() {
 checkToSkip(1)("test1", function() {\*test goes here*\});
 checkToSkip(4)("test2", function() {\*test goes here*\});
});

function checkToSkip(now) {
    return now > 3 ? it : xit; 
   //return now > 3 ? it : it.skip; 
}

Here 'test1' will be skipped as 'checkToSkip' returns 'xit' (or it.skip). Is it possible to pass a message to reporter mentioning the reason for the test skip? something like below (or any other possible way).

checkToSkip(4)("test2", function() { \\ test goes here}, "My Skip message!!!!" );

or

checkToSkip(4)("test2", function() { \\ test goes here}).pending("My Skip message!!!!");

Note: Im using mocha in webdriverIO.

Thanks.

@ponmudivn
Copy link
Author

http://stackoverflow.com/questions/31688650/is-it-possible-to-send-a-reason-for-jasmine-2-specs-skipped-with-xit-or-pending

This thread explains the solution for same problem using Jasmine. Im looking for something similar in Mocha.

@vivganes
Copy link
Contributor

vivganes commented Nov 4, 2016

I too would love to have something like that.

I could not find any inputs about how to enter reason for skipping in documentation here

May be a candidate for a feature request? It could just be a case that the documentation is missing while feature is there.

@ponmudivn
Copy link
Author

ponmudivn commented Nov 8, 2016

http://stackoverflow.com/questions/40397201/mocha-setting-message-reason-for-test-skip/40407177#40407177

fyi: a workaround to achieve this is available in above thread.

@boneskull boneskull added the type: feature enhancement proposal label Nov 17, 2016
@boneskull
Copy link
Contributor

this would be a good usability improvement, but see @ponmudivn's workaround

@boneskull boneskull added the area: usability concerning user experience or interface label Nov 17, 2016
@jeffvandyke
Copy link

One approach that could cover all use cases and would only be a small api change would be to allow an optional reason parameter to this.skip(). The it.skip(...) case could be satisfied by just calling this.skip("reason") in the first line of the test.

@monkey-programmer
Copy link

Agreed with @jeffvandyke I would love to have this feature

@Nokel81
Copy link

Nokel81 commented Apr 11, 2018

How about doing:

    it.skip("A test").reason("Code has changed");

But that doesn't allow for using the this.skip api, so maybe it can also accept a second or third string parameter as the reason as well. But that just seems weird in my opinion.

@boneskull
Copy link
Contributor

duplicate of #2026

@Pependuez
Copy link

One more workaround

it('My cool test', async function() {
  if (this.response.status !== 201) {
   this._runnable.title += ' - Skipped with reason: wrong response code'
   this.skip()
  }
  expect(this.response.data).to.have.property('mycoolproperty')
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: usability concerning user experience or interface type: feature enhancement proposal
Projects
None yet
Development

No branches or pull requests

7 participants