polymerpolymer-1.0polymer-3.xweb-component-testerwct

How to test service files using wct in polymer if it doesn't contain any custom component


I would like to write unit test case for a service file named session.js, where there is no custom element is defined. Can we call functions defined in service file from Polymer WCT.

export const ValidateSession=()=>{  
       try{   
           return (logindate <= session);   
       }
       catch(e){   
           console.log(e.message);   
       }   
   }

In my service file, function is defined like above. How to write unit test case to check above function is being called or not.


Solution

  • Do everything you would do to test an element, but without an element fixture, or perhaps using a JS-only test suite:

    suite('AwesomeLib', function() {
      test('is awesome', function() {
        assert.isTrue(AwesomeLib.awesome);
      });
    });
    

    Such test suites are described in the WCT README.