background preloader


Related:  Développement Web

Performance testing and measuring the page load time of web aplications using PhantomJS and Google charts | Load Testing for Websites Blog Performance testing the page load time of a web application can be a little tricky but pretty useful for simulating what the user experience of your customers. The following solution uses the PhantomJS headless browser for measuring the needed timing information, Google charts for visualizing the results. The solution can also be used pretty much as it in the continuous integration environment based on Jenkins or any other system. For what can I use this solution ? page load time testingsize and number of resources retrieved for URL callload time for each resource The solution described below is composed of the following scripts and executables: 1. Steps to make the solution work for you (Linux OS as this is what I have , similar on MacOS or Windows). 1. browse to a terminal window and issue wait for PhantomJS to be downloaded and issue the command “ “now PhantomJS is installed 2. 3. 4. 5. The results should look like below:

Lazy.js - v0.3.2 Lazy.js is a functional utility library for JavaScript, similar to Underscore and Lodash, but with a lazy engine under the hood that strives to do as little work as possible while being as flexible as possible. It has no external dependencies, so you can get started right away with: (Note the package is called "lazy.js", with a dot.) Or, if you're using Lazy.js in the browser: Now let's look at what you can do with Lazy.js. (For more thorough information, take a look at the API Docs.) Introduction Let's start with an array of objects representing people. var people = getBigArrayOfPeople(); Suppose we're using this array to back some sort of search-as-you-type functionality, where users can search for people by their last names. var results = _.chain(people) .pluck('lastName') .filter(function(name) { return name.startsWith('Smith'); }) .take(5) .value(); This query does a lot of stuff: There—now we haven't created any extraneous arrays, and we did all of the work in one iteration. Well, yeah.

Nightwatch.js krasimir/bubble.js Mocking Requests with Mocha, Chai and Sinon | Rob Dodson talks internets After a bit of a rocky start yesterday I’ve finally got Mocha and Chai running in the browser which is great. Today I’d like to test out some of the async functionality of Mocha. This seems to be the big selling point for most people so we’ll kick the tires a bit. Basic Async Tests with Mocha and Chai I wrote a little Node service that we’ll consume for testing purposes. We’ll need to make sure our node service is running for our tests to work and all of our URLs will point at localhost:3000. Here is our really simple Mocha spec. I just want to see if the ajax methods will run and hit our Node service but I’m running into the following issue in Chrome: XMLHttpRequest cannot load Bummer… :( OK, what’s going on here… To StackOverflow! OK hopefully we’re done with Node for now. Enter Sinon.js I’m going to use Sinon.js to help me mock, stub, fake, spy and do whatever the heck else I need to make sure my client code is solid. Failing as expected.

SweetAlert A beautiful replacement for Javascript's "Alert" So... What does it do? Here’s a comparison of a standard error message. The first one uses the built-in alert-function, while the second is using sweetAlert. Normal alert Code: alert("Oops... Sweet Alert sweetAlert("Oops Pretty cool huh? More examples In these examples, we're using the shorthand function swal to call sweetAlert. Download & install Method 1: Install through bower: $ bower install sweetalert Method 2: Download the sweetAlert CSS and JavaScript files. Configuration Here are the keys that you can use if you pass an object into sweetAlert: Contribute

Testing Handlebars With Mocha - No F*cking Idea Mocha and Handlebars are two great things i use. Mocha is a testing library which can be used for backend (node.js) and fronend testing. On frontend its only dependency is jQuery. Handlebars is templating language that can be used for frontend javascript partials or even for backend (node.js) layouts. What ever you want! When i started working with express.js sinatra like framework i took a peek at other projects that people from Vision Media do. Chai.js / Should.js Because Mocha is not shipped with everything i like i decided to use should.js on backend (node.js) and chai.js on frontend to make my tests suits more rspec like. I really like this; syntax. Second very useful thing that i never skip in my project is Handlebars, easy to use and clean language to build templates in javascript. This sample show how to in easy way embed handlebars into your html code. Step one Bang everything works fine :).

Platform En ajoutant le bouton de connexion "Google+ Sign-In" sur votre site, vous bénéficiez de toute la puissance de Google. Lorsqu'un utilisateur est connecté, vous recevez un jeton OAuth vous permettant de formuler des requêtes API en son nom. Ainsi, vous pouvez mieux cerner l'utilisateur, le connecter à ses amis et créer une expérience plus riche et intéressante. Vous pouvez également ajouter le bouton "Google+ Sign-In" à votre application Android ou iOS. La première fois qu'un utilisateur clique sur le bouton de connexion, une boîte de dialogue d'autorisation s'affiche. Un utilisateur a toujours la possibilité de révoquer l'accès à une application à tout moment. Essayer Le bouton ci-dessous déclenche le processus de connexion OAuth 2.0 et génère l'objet de résultat d'autorisation. Sélection d'un processus de connexion Plusieurs options de gestion du processus de connexion s'offrent à vous : Le processus côté client, qui utilise les langages JavaScript et HTML. Étape 4 : Gérer la connexion

4. Testing TDD? The best way to make code testable is to start by writing the tests first - TDD style. Essentially, TDD boils down to: TDD is a set of rules for writing code: you write a failing test (red), then add just enough code to make it pass (green) and finally refactor where necessary (refactor). In this chapter, we discuss how to set up testing for your project using Mocha, how to do dependency injection for your CommonJS modules, and how you can test asynchronous code. The rest is best covered by some other book or tutorial; so if you haven't heard of TDD, get out from under that rock you've been living under and read Kent Beck's book and perhaps Michael Feather's book. Why write tests? Test driven development is not valuable because it catches errors, but because it changes the way you think about interfaces between modules. In most cases, you don't completely understand the system when you start writing it. What to test? Test frameworks Setting up and writing a test Basic assertions

Login for the Web Using the JavaScript SDK If people using your app aren't logged into your app or not logged into Facebook, you can use the Login dialog to prompt them to do both. Various versions of the dialog are shown below. If they aren't logged into Facebook, they'll first be prompted to log in and then move on to logging in to your app. The JavaScript SDK automatically detects this, so you don't need to do anything extra to enable this behavior. There are two ways to log someone in: Using the Login Button Including the Login Button into your page is easy. Note that in the example at the start of this document, we use the onlogin attribute on the button to set up a JavaScript callback that checks the login status to see if the person logged in successfully: This is the callback. function checkLoginState() { FB.getLoginStatus(function(response) { statusChangeCallback(response); });} Invoking the Login Dialog with the JavaScript SDK Handling Login dialog response Asking for Permissions

Testing your frontend JavaScript code using mocha, chai, and sinon | Code As rich Web application complexity grows, if you want to keep your sanity, you need to unit test your frontend JavaScript code. For the 4 past months, I've been working for Mozilla on some big project where such testing strategy was involved. While I wish we could use CasperJS in this perspective, Firefox wasn't supported at the time and we needed to ensure proper compatibility with its JavaScript engine. So we went with using Mocha, Chai and Sinon and they have proven to be a great workflow for us so far. The mocha testing framework and the chai expectation library Mocha is a test framework while Chai is an expectation one. So let's say we have a Cow object we want to unit test: Nothing fancy, but we want to unit test this one. Both Mocha and Chai can be used in a Node environment as well as within the browser; in the latter case, you'll have to setup a test HTML page and use special builds of those libraries: My advice is to store these files in a vendor subfolder. <!