Skip to content

Instantly share code, notes, and snippets.

@sibinx7
Last active December 28, 2018 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sibinx7/51c84cb85562b5a2bc714f1174e11fa0 to your computer and use it in GitHub Desktop.
Save sibinx7/51c84cb85562b5a2bc714f1174e11fa0 to your computer and use it in GitHub Desktop.
JavaScript Helper website

Learn latest ES6 & ES7 properties

ES6-Features

Javascript reference

Mozilla Developer Network

Realtime Chat/Application

NPM Update plugin

NPM UPDATE

Payment related

Datatable - Advanced

SVG/Canvas

filtering/Sorting and Grid plugins

Table related

Videos

Debates

CSS and JS

Snippets

  1. Protractor skip some test conditionally. Example code

Should add ignore function at top, and we call this ignore in it block.

var ignore = function(exp){return{it:((typeof exp==='function')?exp():exp)?function(){}:it}};

describe('Suite 1', function() {

    it("test a", function() {
        expect(1).toEqual(1);
    });

    ignore(true).it("test b", function() {
        expect(1).toEqual(1);
    });

    ignore(skip).it("test c", function() {
        expect(1).toEqual(1);
    });

    function skip(){
      return true;
    }
});
  1. Protractor test hidden element, deal with hidden elements
var elm = element(by.id("myid"));
browser.executeScript(function (arguments) {
    arguments[0].style.visibility = 'visible'; 
    arguments[0].style.display = 'block';
}, elm.getWebElement());
  1. Protracot to access local Storage
var value = browser.executeScript("return window.localStorage.getItem('key');");
expect(value).toEqual(expectedValue);
  1. Get value from trustedResourceURL
var trustedResource = $sce.trustAsResourceUrl("www.abcd.com/folder/image.png");
$sce.valueOf(trustedResource); // "www.abcd.com/folder/image.png"
  1. Goto element in Angular
   $scope.gotoBottom = function() {
      // set the location.hash to the id of
      // the element you wish to scroll to.
      $location.hash('bottom');

      // call $anchorScroll()
      $anchorScroll();
    };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment