GithubHelp home page GithubHelp logo

Need Help for testing about bliss HOT 29 CLOSED

leaverou avatar leaverou commented on May 20, 2024
Need Help for testing

from bliss.

Comments (29)

LeaVerou avatar LeaVerou commented on May 20, 2024

Hey there, thanks for contributing!
There is no click method on li elements. Only some types of elements have this natively (e.g. a elements).
If you were trying to fire a click event on the element, change it to:

$('#tete li')._.fire("click");

(in a rush so haven’t checked the rest of the code)

from bliss.

wcastand avatar wcastand commented on May 20, 2024

Thank for the answer.
I guess chrome add itself the click function on all the elements because it worked on my test to understand delegate in chrome :)

When i use the fire function, i have no error but it didn't fire the click function from the $.delegate
I used the same code as my first post, except the line :

$('#tete li').click();
//replace by
$('#tete li')._.fire("click");

I don't know if i have to open an other issue. But when i try to create an element with the property 'events', i get an error:

$.create("a", {
    href: "#here",
    title: "Permalink",
    className: "permalink",
    events: {
        click: function(evt) {
            console.log("test")
        }
    }
});
ReferenceError: Can't find variable: EventTarget
            at F:/Web/bliss/bliss.js:408
            at F:/Web/bliss/bliss.js:328
            at F:/Web/bliss/bliss.js:566
            at F:/Web/bliss/bliss.js:588
            at F:/Web/bliss/bliss.js:88
            at F:/Web/bliss/tests/Events/DelegateSpec.js:15

from bliss.

LeaVerou avatar LeaVerou commented on May 20, 2024

I think you're using an older version. Please pull?

from bliss.

wcastand avatar wcastand commented on May 20, 2024

Ok, i update my fork and it works. My bad here

Anyway for the test of delegate, it still doesn't work.

it("add event on children of subject", function() {
        var test = false;
        var subject = document.createElement("div");
        subject.id = "tete";
        var aa = $.create("a", {
            href: "#here",
            title: "Permalink",
            className: "permalink",
            events: {
                click: function(evt) {
                    console.log("testa")
                }
            }
        });
        subject.appendChild(aa)
        document.body.appendChild(subject);
        var tt = subject._.delegate("click",
        {
            a: function(){
                console.log("tea");
                test = true;
            }
        });
        $('#tete a')._.fire('click');
        expect(test).to.be.equal(true);
    });
LOG: 'testa'
PhantomJS 1.9.8 (Windows 8 0.0.0) $.delegate add event on children of subject FAILED

So when i fire 'click', the callback from the $.create works but the one from delegate doesn't.
I try to remove the event from the $.create and the result is the same.
Maybe i didn't understand how to delegate function work :/

from bliss.

guoguo12 avatar guoguo12 commented on May 20, 2024

So I rewrote the test to work independently of other Bliss methods. (I hope you don't mind, @wcastand.)

I think the issue here is that $.delegate legitimately doesn't work on PhantomJS. When I run my test, I'll get an error like

PhantomJS 1.9.8 (Windows 8 0.0.0) $.delegate adds event to children of the subject FAILED
        TypeError: 'undefined' is not a function (evaluating 'evt.target.matches(selector)') (C:/Users/guogu_000/Git/bliss/bliss.js:480)

indicating that Element.matches isn't valid in PhantomJS. Replacing Element.matches with Element.webkitMatchesSelector makes the test pass on PhantomJS.

[Note: I force-pushed over commit 39c214e, so that's why it shows up twice. Didn't know the mention wouldn't go away. Sorry!]

from bliss.

wcastand avatar wcastand commented on May 20, 2024

Hi,
I don't mind at all. Thanks for the help !
I will continue to test the others methods of Events.

from bliss.

zdfs avatar zdfs commented on May 20, 2024

This begs the question, should we have tests that only execute in a real browser and tests that execute in a headless env? The strategy being that we try to make something work in Phantom, and if we can't, save it for when the developer is using a real browser.

Just throwing out ideas.

from bliss.

guoguo12 avatar guoguo12 commented on May 20, 2024

Honestly, I wouldn't mind. PhantomJS is being really buggy for me on watch mode. I'll karma start and everything will pass, and then I'll save one of the test files without changing anything and PhantomJS will fail. Am I missing something about how PhantomJS operates during watch mode?

from bliss.

wcastand avatar wcastand commented on May 20, 2024

I actually had the same issue when i was trying to figure it out delegate. Sometime my test just didn't pass on my DelegateSpec.js and at one point i get an error on a bliss file. i just save the file again and the error disappear.
I didn't understand why.

from bliss.

zdfs avatar zdfs commented on May 20, 2024

Actually, maybe we can use Firefox. Travis-ci seems to have support for that.

from bliss.

zdfs avatar zdfs commented on May 20, 2024

I'm going to change our config to Firefox, and see if Travis builds. Probably better if we use a real browser if Travis supports one.

from bliss.

zdfs avatar zdfs commented on May 20, 2024

Ok. I think I'm almost there.

from bliss.

zdfs avatar zdfs commented on May 20, 2024

Ok. It seems to be running the tests with Firefox now, but can anyone tell me if it's really running the tests or not. It seems like it is, but the counts are off: https://travis-ci.org/LeaVerou/bliss/jobs/95623030

from bliss.

zdfs avatar zdfs commented on May 20, 2024

According to the screenshot here (http://www.sitepoint.com/testing-javascript-jasmine-travis-karma/), it seems like that's the normal behavior.

from bliss.

zdfs avatar zdfs commented on May 20, 2024

And I see 27 SUCCESS lines. So I think we can have a normal test now instead of some special PhantomJS version. @wcastand and @guoguo12, is there any cleanup we need to do since we have a Firefox test environment on Travis now?

from bliss.

guoguo12 avatar guoguo12 commented on May 20, 2024

Okay, great. I don't think there's any cleanup that needs to be done.

from bliss.

zdfs avatar zdfs commented on May 20, 2024

Close this one out then?

from bliss.

guoguo12 avatar guoguo12 commented on May 20, 2024

Sure.

from bliss.

LeaVerou avatar LeaVerou commented on May 20, 2024

Thank you all!
Sorry if this is a silly question, but why Firefox and not Chrome? AFAIK there is a Chrome launcher too…

from bliss.

zdfs avatar zdfs commented on May 20, 2024

Firefox is already on Travis. From what I've read, it seemed like I would need steps to build and install Chrome.

I can try Chrome and see what happens. We can always go back to Firefox.

from bliss.

zdfs avatar zdfs commented on May 20, 2024

I'm curious now. Going to try it.

from bliss.

LeaVerou avatar LeaVerou commented on May 20, 2024

Given that Chrome has a much higher market share, I’d prioritize that. But if it's too much of a hassle, Firefox is fine!

from bliss.

zdfs avatar zdfs commented on May 20, 2024

Ok. Looks like we can't start Chrome. I can get this to work. I've done it on Wercker. But it's going to take me a few tries. I don't mind.

from bliss.

zdfs avatar zdfs commented on May 20, 2024

Holy shit.

screen shot 2015-12-08 at 11 20 52 am

from bliss.

zdfs avatar zdfs commented on May 20, 2024

Chrome is set. Closing this out.

from bliss.

guoguo12 avatar guoguo12 commented on May 20, 2024

Good work!

from bliss.

dperrymorrow avatar dperrymorrow commented on May 20, 2024

@zdfs if we are going to run the suite in Chrome, should i back out that change i made to get $.all to run in headless mode?

the expr.constructor.name vs instanceof business

from bliss.

zdfs avatar zdfs commented on May 20, 2024

You can do that. I can merge something like that as opposed to changes that affect core code.

from bliss.

LeaVerou avatar LeaVerou commented on May 20, 2024

Thank you so much @zdfs!

from bliss.

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.