1

Does expect() have a return type (or a promise it fulfills)? If not, how can I store/access the result of an it('should...')'s expect()?

Edited-Clarification: I want to store and use these results during subsequent tests.

Reason: I'd like to make some tests resilient enough to know if they should be skipped because prior tests failed, without having to make the comparison a second time and wait for nested promises to all resolve again.

1 Answers1

1

Have a look at the http://jasmine.github.io/2.3/custom_reporter.html which allows you to be notified of the suite/specs success/failure as they are executed.

You could then store this information in an object which could then be accessible to your specs.

asa
  • 1,776
  • 2
  • 11
  • 10
  • I was hoping to not have to bother making my own reporter. Jasmine claims > `None of the functions here are required when creating a custom reporter, any that are not specified on your reporter will just be ignored.` Does this mean it will retain normal Jasmine reporting functionality? Or it will just do nothing for not-given functions? – Josh Longerbeam Jul 21 '15 at 21:16
  • Your use case is a bit uncommon, and I'm not aware of another way to dynamically disable specs based of a failure of a previous one. Saying this don't be afraid of the custom reporters, it's very easy to implement them and in fact in your case you only need the `specDone` one. – asa Jul 21 '15 at 21:21
  • I'll bump it lower on my to-do list for now. But when I get to it, I'll try it. Thank you! – Josh Longerbeam Jul 21 '15 at 22:44
  • sorry didn't notice your questions in your comment. as far as I know it does only add reporters and does not replace the existing ones. I didn't notice any changes in the output of my project using karma, with or without custom reporters. – asa Jul 22 '15 at 05:35