DrupalCon Prague 2013

Testeando el código JavaScript

Théodore Biadala, Jesse Beach, Steve De Jonghe  · 

Transcripción

Extracto de la transcripción automática del vídeo realizada por YouTube.

photos looking for the search lab that's not here it's in club H room down the corridor so so many people for JavaScript that's unusual yeah of course we were wondering if root and get like two people are 50 people we're really one Shore so

if you if you're checking Twitter the last tweet to the drupalcon hashtag has a link to a document where we can take notes so if you want to take notes while we're in the session you can all take them in the same document and you'll have it perpetuity

user might or until Google+ up or the Sun experiences heat then whichever happens first alright so today we're going to talk about javascript testing it's more going to be as presenting to you what we currently have and what we currently do and basically

asking you what you would do if you could you know implement testing for Drupal core so if you have ideas of a specific framework or specific saying we should be using to do javascript testing well let us know it's a conversation it's not a cop presentation

so stop us anytime and so first why do we want JavaScript testing because it makes maintenance easier when we refactor it makes sure we don't break stuff drink the eight release we already broke views you I states overlay table drag verge kept tabs collapsible

field sets contextual and probably some other we don't know about so I mean testing is good so that's what we want it's been pretty painful and now you know web chic is a bit scared when they when she commits JavaScript patch because there's

no testing so it gets in a way the testing scope currently in co we have 107 you know custom Drupal JavaScript files and none of that is tested or what very few very little of that is tested yeah and you know that's not great so first we can test the actual

code itself so that tools like just hint just rent these kind of things to make sure that you know the syntax is correct and this kind of things but it doesn't do anything for the actual behavior and the interaction that the javascript is supposed to provide

so I guess the first question to you is we need to integrate gia sent to test but to make sure that at least all core java script patch follow the jason configuration we have in Drupal 8 so we will need you know someone who is willing to integrate that with

a test but because it might be a bit you know take a bit of time and a bit of effort so we might be interesting in doing something like that I'm gonna add a volunteers section to the document you can put your name yeah I imagine that's gonna be one

of the hardest things to find a volunteer for test spot so should she dress pick one yeah number 17 yes we could put that in Kedah module yeah actually but since it's require some no GS stuff it might not be straight forward 20 grades but we can try so

yeah jacent or could a desert orchid our module you should mention that in Drupal 8 core at the root there's a chase hint RC file yep which automatically sets the correct configurations on Jason so if you if you have it installed locally through like I

think brew will install it maybe you're like NP I can't remember which one of the package managers doesn't but if you run it from Drupal core on a particular file its going to pick up the correct configurations and also it's picked up by ID

like well personally I phpstorm but you know whatever is integrated with jacent its picks it up and run the test when you edit a file that's helpful which mentioned to those a policy at the moment in core of absolutely no messages no warnings nothing goes

wrong with J's hint when you run it I run into this all the time because I'm okay with warnings personally but node once zero output so that he can run it and get a clean chase hint so it sometimes means you have to play some games with the JavaScript

but yeah it's kind of nice when it when there are 0 things coming out of it so i guess like who who we are in that project use jacent or some kind of validation tool for javascript files that's good so I mean is this kind of changes that you want to

see in Drupal core because I mean we did that assuming that you would want to run it for your country module as well yeah so that's going to happen for country at least some of it and if you have any feedback on the core configuration feel free to send

an issue or open something in the issue queue to change some settings that you know not set in stone yet I guess we're done with this topic or do you have anything else to add about just code verification testing maybe you could describe what Jason does

I think we have a site about that yeah that's right oh yeah so who didn't know about Jason oh okay sorry about that so jacent command line tool that you run and it will verify your Java JavaScript files for some very easy and common mistakes that can

be made like you know you don't declare your variable so it ends up as a global variable that's bad so Jason will tell you you need to change this and this variable and declare it properly also in the brackets on if-else these kind of things yes in

tax verification and if if you want to know more about that Jason dot org just maybe more explanation than then what I give you yeah so I guess the current fought the actual behavior and the interaction testing what we currently use is a test warm so that's

been written by attics wrote like pretty much older useful stuff in Drupal 8 as fast JavaScript goes like the picture modules at same the swamp and yeah although other things and so test for module with Q unit testing soak unit is the framework that Jaguar

uses for its own testing then we have the fat module that goes with it which is a front end automated test testing test very fast something like that it was all made up for the acronym anyway and yeah that she was clean it as well so I guess the question is

do any of you already use the test to our module for Drupal for testing your stuff 1122 okay hey I know used it so um and also is it just right after all we're going through a testing test some test example yeah I'll explain kind of what it does drove

it at the code and then Steve has a running example of our current suite of tests maybe it ran like three seconds ago we'll see if we can show this look like so the output of tests swarm is essentially a table that tells you you know if all the chests

in within a particular group past or if they failed you can drill down into a particular failing test it doesn't tell you why it failed that's you know something that developers to figure out and it's a fairly basic presentation I think you know

in terms of our tools this is version 0.01 it doesn't it's not very usable I'll just say that like it takes a lot of tinkering you have to know specific URLs to go to it often fails on obscure Ajax errors this is something that we're all building

in our spare time and bugs get fixed when we try to run the tests and they break and you just you have to fix the things you could like get to your tests again so let's go into the next slide so let's look at some of the code that you know what what

a chest in our system would look like essentially what you do is you declare your tests on the drupal tests object as a a method or an object we have it's very similar to simple test in the sense that we have this get info method a set up in a tear down

the difference between the setup and the teardown is that we don't have the separate you know encapsulated installation that simple test does where you have to essentially build your installation from the ground up you know enabling modules creating users

[ ... ]

Nota: se han omitido las otras 3.826 palabras de la transcripción completa para cumplir con las normas de «uso razonable» de YouTube.