title: How to setup Jest for Unit testing normal with php project?
body: <p>I need to setup the front end unit test for my PHP project.
  I decided to go with Jest.</p>
  
  <p>So this is my package.json.</p>
  
  <pre><code>{
    "name": "staging-deploy",
    "version": "1.0.0",
    "description": "Staging deploy",
    "main": "GulpFile.js",
    "author": "some one",
    "license": "BSD-2-Clause",
    "dependencies": {
      "bower": "^1.8.0",
      "gulp": "^3.9.1",
      "gulp-autoprefixer": "^3.1.1",
      "gulp-chmod": "^2.0.0",
      "gulp-closure-compiler": "^0.4.0",
      "gulp-concat": "^2.6.1",
      "gulp-cssnano": "^2.1.2",
      "gulp-duration": "0.0.0",
      "gulp-jasmine": "^2.4.2",
      "gulp-less": "^3.3.2",
      "gulp-load-plugins": "^1.4.0",
      "gulp-pixrem": "^1.0.0",
      "gulp-postcss": "^6.3.0",
      "gulp-replace": "^0.5.4",
      "gulp-sourcemaps": "^1.11.0",
      "gulp-update": "0.0.2",
      "gulp-update-modul": "^1.5.5",
      "gulp-watch-less": "^1.0.1",
      "run-sequence": "^2.0.0"
    },
    "devDependencies": {
      "jest": "^20.0.4"
    },
    "scripts": {
      "test": "jest"
    }
  }
  </code></pre>
  
  <p>Then I made <code>__tests__</code> folder and making my first testing function like this.</p>
  
  <p>// homepage.test.js</p>
  
  <pre><code>require('../modules/homepage.js');
  
  test('adds 1 + 2 to equal 3', function() {
      expect(Homepage.sum.sumNumber(1, 2)).toBe(3);
  });
  </code></pre>
  
  <p>And this is my homepage.js</p>
  
  <p>// homepage.js</p>
  
  <pre><code>var Homepage = {};
  
  (function() {
      "use strict";
  
      Homepage.sum = {
          sumNumber: function(num1, num2) {
              return num1 + num2
          }
      };
  })();
  </code></pre>
  
  <p>Then I ran <code>npm run test</code>
  This is what I got:</p>
  
  <pre><code>FAIL  __tests__/homepage.test.js
    ● adds 1 + 2 to equal 3
  
      ReferenceError: Homepage is not defined
  
        at Object.&lt;anonymous&gt; (__tests__/homepage.test.js:4:12)
        at Promise.resolve.then.el (node_modules/p-map/index.js:42:16)
        at process._tickCallback (internal/process/next_tick.js:109:7)
  
    ✕ adds 1 + 2 to equal 3 (2ms)
  
  Test Suites: 1 failed, 1 total
  Tests:       1 failed, 1 total
  Snapshots:   0 total
  Time:        3.138s, estimated 11s
  </code></pre>
  
  <p>Seems like my test file can not access the function inside my Homepage.js file.</p>
  
  <p>How can I fix this and make it works?</p>
  
  <p>Thanks</p>