GithubHelp home page GithubHelp logo

Comments (8)

bingomanatee avatar bingomanatee commented on May 22, 2024

along those lines: the idea that showTest method simply shows a line on the screen is not in keeping with any test system currently in use in JavaScript.

Most systems capture and log errors when test conditions are not valid;

The accepted practice in testing is to throw an informational error as in:

    client.showTest = function(theTest, receivedValue, expectedValue, message) {
        if (!theTest){
            throw new chai.AssertionError({actual: receivedValue, expected: expectedValue, message: message})
        }
    };

While using a test-system-resident error class isn't the way to go for general practice, this does seem to be the pattern for general use.

from webdriverio.

christian-bromann avatar christian-bromann commented on May 22, 2024

Hi @bingomanatee

webdriverjs should not stop or fall in an endless pause because of chai. I tried to reconstructed this use case with the following test:

it.only('should not stop if chai assert fails',function(done) {
    client
        .url(testpageURL)
        .isVisible('.btn1_clicked',function(result){
            assert.strictEqual(false,true);
            done();
        });
});

This test fails but it ended. I stumpled several times on a similar problem when I executed the end function without creating a new session with init before the next test started. Did you find a solution for that?

greetings

from webdriverio.

christian-bromann avatar christian-bromann commented on May 22, 2024

Ok, I've probably found the reason why the test stops.

In this line the callback of the current command gets fired after the respond arrived. In this callback a error could be thrown by any assertion library like chai. This stops the process and the next command self.next(); never gets fired to continue with the next command.

The test above works, because no other test waited for execution. The after function was executed and ended the test.

I will wrap this part of code in a try catch to avoid this.

thanks for filing this issue!

from webdriverio.

christian-bromann avatar christian-bromann commented on May 22, 2024

Ok..a try catch doesn't work because the Chai Assertion error never gets thrown and a falsely test gets marked as true.

from webdriverio.

christian-bromann avatar christian-bromann commented on May 22, 2024

Now I found a nice solution.

process.on('uncaughtException', function (exception) {
    self.next();
});

If the Chai (or whatever you use) error gets thrown, this callback continues the command queue.

from webdriverio.

roderickhsiao avatar roderickhsiao commented on May 22, 2024

Thanks for your fix Christian, would like to know approximately when will be the release date for the fix (v0.7?) on npm?

Cheers

from webdriverio.

christian-bromann avatar christian-bromann commented on May 22, 2024

now ;-)

from webdriverio.

roderickhsiao avatar roderickhsiao commented on May 22, 2024

Try the latest version and it works !
Just need to perhaps add 'err' for like function(err, results) if you has custom method (previous no 'err' param)

Thanks a lot

from webdriverio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.