title: How can I use jquery inside Nightwatch
body: <p>I have text i need to perform htmlEndcoding on in nightwatch.
  I found a solution but it requires using jquery. I can't figure out how to access jquery inside of Nightwatch. </p>
  
  <p>I found the following <a href="https://stackoverflow.com/questions/1219860/html-encoding-lost-when-attribute-read-from-input-field">htmlEncode</a> this looks like something I could use, but I don't know how to include it in nightwatch. I get '$' undefined. I can see this is for jquery but I don't know how to get to jquery in nightwatch.</p>
  
  <pre><code>function htmlEncode(value){
  // Create a in-memory div, set its inner text (which jQuery automatically encodes)
  // Then grab the encoded contents back out. The div never exists on the page.
    return $('&lt;div/&gt;').text(value).html();
  }
  
  function htmlDecode(value){
    return $('&lt;div/&gt;').html(value).text();
  }
  </code></pre>
  
  <p>I also found <a href="https://stackoverflow.com/questions/36830349/how-to-write-a-nightwatch-custom-command-using-jquery">How to write a nightwatch custom command using jquery</a>, but it comes with the caveat:
  'Note that you do need jQuery available in the global scope of your app for this to work.' ... I don't know how to do this.</p>
  
  <p>I'm a java programmer and I'm new to both nightwatch and javascript. Seems like I should be able to get to jquery via the client or the api, but I cannot figure out how to do it.</p>
  
  <p>Tried several version of the following: </p>
  
  <pre><code>npm install jQuery
  
  var $ = require('jquery');
  
  var $ = require('jQuery');
  
  
  var jsdom = require('jsdom').jsdom
   , myWindow = jsdom().createWindow()
   , $ = require('jQuery')
   , jq = require('jQuery').create()
   , jQuery = require('jQuery').create(myWindow)
   ;
  </code></pre>