Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to force Protractor to pass or skip a test with a message to the console?

I'm working with a system that has several external system dependencies. These external systems are only hooked into certain SDLC environments (local, dev, qa, and prod). Due to these restrictions, I have put environment checks in place on my some of my protractor tests to determine which environment they are in before executing.

For example:

'Test A' is being run, but it is dependent on interacting with 'external system 1' which is only enabled for the QA environment. So if 'Test A' is being run in Local, Dev, or Prod then the test will fail with a message to the console using fail().

My question is... Is there a way to force the test to Pass or be Skipped with a message similar to using fail()? I'm trying to delineate between tests actually passing or failing cause of functionality and if the test was simply skipped due to environment dependencies in my reports.

I know you can technically "skip" tests when your use "fdescribe" or "fit" and the console will print out something similar to the below

Executed 1 of 25 specs (1 FAILED) (24 SKIPPED) in 18 secs.

How can I invoke that skipping capability from with my tests?

like image 291
Chris Traynor Avatar asked Sep 08 '15 14:09

Chris Traynor


People also ask

Is protractor going to end?

Protractor launched in 2013 before WebDriver APIs were standard and E2E tests were hard to write, and it tests Angular and AngularJS apps by running them in Google Chrome. It will continue to run until the end of 2022 when Angular 15 will be the last update.

How do you use a protractor to write tests?

Step 0 - write a testProtractor needs two files to run, a spec file and a configuration file. Let's start with a simple test that navigates to an example AngularJS application and checks its title. We'll use the Super Calculator application at http://juliemr.github.io/protractor-demo/. Copy the following into spec.

How do you speed up a protractor test?

To do this is quite simple in protractor. Adding the shardTestFiles and maxInstences to your capabilities config should allow you to (in this case) run at most two test in parrallel. Increase the maxInstences to increase the number of tests run. Note : be careful not to set the number too high.

Is protractor used for unit testing?

While other testing frameworks offer unit testing for Angular web apps, Protractor allows the tester to perform automated functional testing on Angular web apps using Selenium WebDriver. It allows testing of all layers of the application, which ensures high-quality software that is functionally robust.


2 Answers

Add x before it{}

describe("", function() {
});

it('Would perform this test', function() {
});

xit('would skip this test', function() {
});
like image 192
Raghu Ram.k Avatar answered Sep 22 '22 01:09

Raghu Ram.k


Jasmine publishes a global function pending(message), which works pretty the same as fail(message). You should call it inside a spec to mark it as pending (to skip it):

it('should be skipped', function () {
    pending('Force skip');
    expect(true).toBe(true);
});

See a working sample

Here is a section in Jasmine docs about it.

like image 20
Michael Radionov Avatar answered Sep 19 '22 01:09

Michael Radionov