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

skipped tests #50

Open
tamasmahr opened this issue Mar 1, 2017 · 11 comments
Open

skipped tests #50

tamasmahr opened this issue Mar 1, 2017 · 11 comments

Comments

@tamasmahr
Copy link

Hi,

I have a number of protractor tests that do not include any expect() call from Jasmine, but they use browser.wait() calls. When such tests pass, the report contains the Skipped text in the entry for the spec. The passed, failed, skipped counts for the suite are correct.

Does anybody has any idea why should these specs be marked as skipped?

I am using:

  • protractor 5.1.1
  • jasmine 2.5.3
  • protractor-jasmine2-html-reported 0.0.7

Thanks for the help!

@rolobm
Copy link

rolobm commented May 15, 2017

Same problem :(

@tamasmahr
Copy link
Author

Since I left this comment we found that it is bad practice to have tests with no expect call in them. We should not just wait for something to appear in the dom, but we should make an assertion. As a side effect, this problem is solved as well. :)

@hipschen
Copy link

Protractor tests often use ExpectedCondition (EC) in place of an expect call.
http://www.protractortest.org/#/api?view=ProtractorExpectedConditions

When a test has an EC, this reporter includes "Skipped" at the test level but not at the header level.
image

@Nez07
Copy link

Nez07 commented Nov 22, 2017

How can we edit the reporter to disable Skipped text from being shown for such specs that do not include any expect() call from Jasmine, but use browser.wait() calls . Any help will highly appreciated.

@Isaak-Malers
Copy link

I've also been having this issue when "expect" calls are several files removed from the test that is running, for example:

config.js

runs

myTest.js

which requires

page-library.js

which requires

site-library.js

which requires

login.js

In the first describe for myTest;

User should automatically be re-directed to login page if they are unauthenticated

The only expect calls are in in login.js

I suppose the workaround is to put ```expect(true).toBe(true) everywhere where there isn't a naitive expect, but that is a clunky workaround for sure.

@telangn
Copy link

telangn commented Oct 14, 2018

Can you elaborate or show code on how to fix this? All my functions have "expect(data).toBe(myData);"
Is this why my html reports says Skipped for all my 'it''s? I call these functions from my 'it', they exist in another .js file.
@tamasmahr @hipschen

@Isaak-Malers
Copy link

@telangn Certainly, I open sourced all of the code that I used to get around protractor deficiencies in general here:

https://github.com/Isaak-Malers/obverse

The part that you will be interested in is that I add a "step" level to my tests so that I can do the following:

describe(user accounts tests, function(){
    it("should be able to create a new user", function(){
        step("navigate to login page via a tracking link", function(){});
        step("create new account", function(){});
        step("verify account email received", function(){});
    });
});

This way I am still able to get more granular logging and control of my tests, without having to use "it" blocks with effectively no tests in them, which isn't really what the "it" function was meant to do.

@telangn
Copy link

telangn commented Oct 14, 2018

@Isaak-Malers I've looked through your link. I cannot find the above code snippet. Can you direct me?
Also, are you saying by doing the "step" the html report will produce results instead of "skipped"?

Can you show me the above file in addition to where the step is defined and executed?

@Isaak-Malers
Copy link

@telangn

Jasmine has limited support for "it" blocks that don't contain expect calls because the primary purpose of an it block is to contain assertions, as @tamasmahr noted here:

Since I left this comment we found that it is bad practice to have tests with no expect call in them. We should not just wait for something to appear in the dom, but we should make an assertion. As a side effect, this problem is solved as well. :)

I would expect anyone having this issue, is using "it" blocks for too granular of tasks. By adding a "step" function to provide a more granular level of testing, it is possible to consolidate all of the problematic "it" calls into a single block, and organize the test with "steps". For example:

  • describe Wikipedia multi-lingual web search
    • it should be able to change language
    • it should be able to click search
    • it should be able to type a search term
    • it should be be taken to the correct page
      • Expect (somepage)

should really be:

  • describe Wikipedia
    • it should have multi-lingual search functionality
      • step: change language
      • step: click search
      • step: type search term
      • step: EXPECT to be on the correct page
        • Expect (somepage)

Note that in this second example, the first 3 "it" blocks which would have shown up as skipped have been replaced with "steps". The 4th it block has also been replaced with a step, and the assertions/expect performed inside that step will carry up to the parent "it" function, thus aligning with jasmines best practices.

As for code, I feel that the Read-Me/landing page on the obverse repository should be enough to get you started with that code base, but It is a lot of extra stuff beyond my code for test steps. I pulled all that code out into a separate sub-module for you here:

https://github.com/Isaak-Malers/serial-IOC

Specifically take a look at the example protractor test here:

https://github.com/Isaak-Malers/serial-IOC/blob/master/protractor-example/example.js

Note that this repository contains a super minimal amount of code. The full obverse repository has a lot more capability as far as test organization and reliability increase goes.

@telangn
Copy link

telangn commented Oct 15, 2018

Wow, very interesting! @Isaak-Malers Thank you for this. Quick question, I see you new'd up IOC

var IOC = require("../src/serialIOC");
var test = new IOC();//new up an IOC object

And then you use test.step....but where do you declare require('step') ?
Is step just understood by Jasmine? Do I need to do an npm install of it or something?
bc in ../src/serialIOC, this is quite confusing for me - serialIOC.prototype.step = function (comment, functionToRun) { Is there an easier implementation?

Btw, I'm new to protractor/JS (I've been a Java dev for a while), so sorry for the basic questions.

@Isaak-Malers
Copy link

step is a function in the IOC class (or test object). It doesn't need to be required because it gets pulled in with IOC. The "test" object is using the step function to dynamically build promise chains, and the "test" object is where that promise chain is stored.

note that the signature for step is:

step("comment for logging", function);

The function passed into step MUST return a promise. It is just returning out the promise for the protractor API calls (such as browser.get())

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

6 participants