Coder Social home page Coder Social logo

Suggestions about chai-webdriverio HOT 10 CLOSED

marcodejongh avatar marcodejongh commented on August 12, 2024
Suggestions

from chai-webdriverio.

Comments (10)

marcodejongh avatar marcodejongh commented on August 12, 2024

@christian-bromann I hate coffeescript with a passion, but I thought it would be a "easy fix".
I'm gonna re-do this module in ES6 only using the chai-webdriver module as inspiration.

None of the assertions would need a DOM flag perse, it only results in a more explicit API, but I think in most cases it makes sense to get rid of it, but in others it doesn't. For example if you where to implement exist

expect('.some-selector').to.exist;
expect('invalidselector').to.exist;

It becomes hard to tell what exactly you want to assert, because if you check if something is a css selector the 2nd example will return true, because when overriding existing assertions you call the super if it doesn't match your current. But then again the other way of looking at it is that if you add the chai-webdriverio assertion helpers you're going to be using chai in a UI testing way so it might be okay to change some existing behaviour of chai.

I just have 1 question for you, how would you recommend finding out if the current mode is promise or sync based? I'd rather not just look for .then, so if there's another way please let me know

from chai-webdriverio.

marcodejongh avatar marcodejongh commented on August 12, 2024

@christian-bromann Finished the rewrite, I've only implemented the methods I need right now but everything is ES6 and properly unit tested.

I think I'll implement promise based use later when I have the time. I'm thinking of wrapping the client with a fibers layer so it behaves synchronous in my tests. What do you think? I haven't looked at the wdio cli tool yet but I'd assume that's how it works

from chai-webdriverio.

christian-bromann avatar christian-bromann commented on August 12, 2024

promise or sync based?

it is sync based when there is a global browser object that is an instance of WebdriverIO and the following is true: `.options.sync.

wrapping the client with a fibers layer

I am not sure if this is possible. To do so you need to also overwrite the it method or at least something that you can give a promise (a future object) and the execution stops until that is resolved.

In general having that plugin for sync mode only is absolutely fine. Remember that for async you can still transfer promises to chai and use chai-promise to write code like:

    it('should contain a certain text after clicking', function() {
        return client
            .click('button=Send')
            .isVisible('#status_message').should.eventually.be.true
            .getText('#status_message').should.eventually.be.equal('Message sent!');
    });

which is basically the same.

from chai-webdriverio.

jedwards1211 avatar jedwards1211 commented on August 12, 2024

@christian-bromann I'm confused about the chai-as-promised chains in your example. You're chaining them onto a webdriverio client object, right? I don't see how they would work without being chained onto expect.

I hate node-fibers with a passion, so I may at some point work on my own chai plugin for doing async webdriverio assertions.

from chai-webdriverio.

christian-bromann avatar christian-bromann commented on August 12, 2024

@jedwards1211 I would recommend to use expect-webdriverio from now on. It also supports async command execution.

from chai-webdriverio.

jedwards1211 avatar jedwards1211 commented on August 12, 2024

sigh, I'm using chai though, not expect

from chai-webdriverio.

jedwards1211 avatar jedwards1211 commented on August 12, 2024

I often end up wishing a lot of assertion utilities like this were standlone libs instead of plugins for the disparate assertion frameworks out there

from chai-webdriverio.

jedwards1211 avatar jedwards1211 commented on August 12, 2024

Okay I made an async fork of this: https://github.com/jcoreio/chai-webdriverio-async

from chai-webdriverio.

christian-bromann avatar christian-bromann commented on August 12, 2024

so there is no chance to incorporate it into this library?

from chai-webdriverio.

jedwards1211 avatar jedwards1211 commented on August 12, 2024

it's certainly possible, I just have so much work to get done ATM I didn't want to make a PR and wait for it to get approved. I found out recently that Chai/Mocha's not as popular as Jest/Expect these days, and this package doesn't have many stars...anyone who needs async (which is more of a minority I assume) can now use my fork anyway, so I just didn't think it was the best use of my time making a PR to this package

from chai-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.