title: How to run Jest test cases with Vanilla JS?
body: <p>I am trying to run test cases using jest with vanilla javascript.</p>
  
  <p><strong>login.test.js</strong></p>
  
  <pre><code>import { validateEmail } from '../assets/js/common';
  
  describe('validate email', () =&gt; {
      it('should pass with valid email', () =&gt; {
          const result = validateEmail('example@test.com');
          expect(result).toBe(true);    
      });
      it('should fail with invalid email', () =&gt; {
          const result = validateEmail('exampletest.com');
          expect(result).toBe(false);    
      });
  })
  </code></pre>
  
  <p><strong>common.js</strong></p>
  
  <pre><code>export const validateEmail = (email) =&gt; {
      return email &amp;&amp; EMAIL.test(email);
  }
  </code></pre>
  
  <p>When I run <code>npm run test</code>, it is throwing </p>
  
  <blockquote>
  <pre><code>({"Object.&lt;anonymous&gt;":function(module,exports,require,__dirname,__filename,global,jest){
  </code></pre>
    
    <p>import { validateEmail } from '../assets/js/common';</p>
  
  <pre><code>           ^^^^^^
  
  SyntaxError: Unexpected token import
  </code></pre>
  </blockquote>
  
  <p>I followed many threads on GitHub but no use. They are saying about React, react-native, and also Babel config etc. But I don't have any <strong>.babelrc</strong> in my project. It's just html, css, pug, js and webpack.</p>
  
  <p>Below is my project directory structure.</p>
  
  <p><a href="https://i.stack.imgur.com/vjUD2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vjUD2.png" alt="enter image description here"></a></p>