Is it possible to use both hard assert and soft assert in a single Spec file

174 Views Asked by At

Is it possible to use both hard assert and soft assert in a single Spec file or within a it block

I got a requirement to apply both Soft Assert and hard assert in single Spec. Soft Assert: If we use normal "expect" validation,it work as Soft assert hard assert: Using Fail Fast in OnPrepare of Export.config file, we can achieve this. Any failure in expect will stop there and skip all subsequent it block and move to next Spec file.

I tried the above asserts and I could able to achieve either one of the assert in my it block. But my requirement is I need to find a way to implement both in the single it block. This task is assigned as R&D to me.

Hard Assert in export.config file.

onPrepare: function() 
{
jasmine.getEnv().addReporter(failFast.init());
},

I am expecting solutions for my two requirement below. 1. How to put the fast fail in Spec file rather than the export.config. 2. How to implement both Soft assert and hard assert in Single "it" block. I have been using either one assert valiations in my previous project. But as part of my new Task, I need to bring some approach to implement both asserts in single it block.

1

There are 1 best solutions below

0
tehbeardedone On

Pretty sure you are doing it wrong. In the config there is a plugins property. This is where you should be registering failfast. Not in the onPrepare. In fact it even shows an exact example of how you should configure it in the documentation for that package.

exports.config = {
  plugins: [
    failFast.init(),
  ]
}