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

Allow pending() in tests #32

Open
juliemr opened this issue Oct 2, 2015 · 16 comments
Open

Allow pending() in tests #32

juliemr opened this issue Oct 2, 2015 · 16 comments

Comments

@juliemr
Copy link
Member

juliemr commented Oct 2, 2015

In the current Jasmine version, there's no way to mark a spec as pending if it's already running asynchronously, which is how jasminewd always runs specs (inside their own controlFlow#execute block). Filed a Jasmine feature request at jasmine/jasmine#937 - but I'm aware that this is probably a strange use case for the pending feature.

@ArturKwiatkowski
Copy link

👍

This is very nice feature when anyone does E2E conditional testing or even if you just want to skip some tests due to some other factors.

@kyleect
Copy link

kyleect commented Aug 30, 2016

Definitely a need for this. We have E2E tests that conditionally run in different parts of the year as features are turned on and off to meet business need. Right now xit().pend('reason') is the only way to do this which is fine but has its own problems.

  1. The jasmine.d.ts file on DefinitelyTyped is horribly out of date and will not compile unless you patch the definition file. I'm working on a pull request to fix that.
  2. The pending reason is at the bottom of the it block. Again you could define the reason text as a variable at the top but its addition overhead.

@mwsessom
Copy link

mwsessom commented Jan 9, 2017

+1

2 similar comments
@formarfr
Copy link

formarfr commented Jan 9, 2017

+1

@order12a
Copy link

+1

@sgibson21
Copy link

sgibson21 commented Feb 28, 2017

I extended the jasmine-spec-reporter (https://www.npmjs.com/package/jasmine-spec-reporter)

var SpecReporter = require('jasmine-spec-reporter');
var PendingSpecReporter = SpecReporter;

PendingSpecReporter.prototype.specDone = function (spec) {
  this.metrics.stopSpec(spec);
  var pending = false;
  for(var i = 0; i < spec.failedExpectations.length; i++) {
    if ( spec.failedExpectations[i].message.toLowerCase().indexOf('pending') >= 0) pending = true;
  }
  if (spec.status === 'pending' || pending) {
    this.metrics.pendingSpecs++;
    this.display.pending(spec);
  } else if (spec.status === 'passed') {
    this.metrics.successfulSpecs++;
    this.display.successful(spec);
  } else if (spec.status === 'failed') {
    this.metrics.failedSpecs++;
    this.display.failed(spec);
  }
};

module.exports = PendingSpecReporter;

Specs marked as pending are displayed as pending in the report if any failedExpectation messages contain the word pending.

@heathkit
Copy link
Contributor

Being able to disable the control flow should also fix this.

@larsgu
Copy link

larsgu commented Feb 22, 2018

Why is it that this still hasn't been acted on?
It seems like an obvious and simple use case, the ability to mark a spec as pending and have it reported as pending, with a reason given by the user.
As it is now, the .pend solution mentioned by @kyleect no longer works, and using pending("reason") inside the spec reports it as failed instead of pending.
Does anyone know of a simple workaround (for Protractor with typescript)?

@maodean001
Copy link

any updates on this issue or just been ignored?

@Kitsula
Copy link

Kitsula commented Jun 8, 2018

Short workaround:
(environment.postDeployment ? xit : it)('should something', () => { expect(true).toBeTruthy(); });

@maodean001
Copy link

maodean001 commented Jun 11, 2018

Thanks Kitsula for your response. I did a similar way to have a logic check switching to xit if it meant to be ignored pro grammatically.

Instead of duplicating (environment.postDeployment ? xit : it) everywhere, I override it and describe global method. If you have test name including special tags e.g. "#dev #test #uat", then I will check if I ignore the tests intentionally and also remove the tags from the test name.

Anyway, it is almost same logic as yours. it works good for me.

Thanks,

@gkalpak
Copy link
Member

gkalpak commented Jul 4, 2018

I haven't tried it, but it might have been fixed since jasmine 2.9: jasmine/jasmine@f4caf27

@mfestrada
Copy link

Short workaround:
(environment.postDeployment ? xit : it)('should something', () => { expect(true).toBeTruthy(); });

Can someone explain what's happening here?

@yayura
Copy link

yayura commented Dec 3, 2018

Can someone explain what's happening here?

(<If it false - test are run, if not - marked as pending> ? xit : it)
('Name of the test', () => {
expect(true).toBeTruthy();
});

@Serginho
Copy link

Serginho commented Jul 7, 2021

Any update on this?

@LynxJ
Copy link

LynxJ commented Jan 3, 2022

Using Jasmine+Protractor and specs with pending() are marked as failed. Would be really nice to have this working properly.

{
       "@types/jasmine": "3.10.1",
        "@types/jasminewd2": "2.0.10"
}

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