Trusted Contributor.. CR Trusted Contributor..
Trusted Contributor..
197 views

Vugen Truclient 12.55 vs 12.60: cannot compile moments.js

Jump to solution

Dear all,

moving from 12.55 to 12.60 I encountered the following issue: the script below (Action.js) works correctly within the 12.55 whereas 12.60 it fails, it cannot compile the moment.js (from https://momentjs.com/) or better it seems it compiles well ( no error) but when moment() is used it triggers the error "moment is not defined"

(function() {
     "use strict";

    TCS.utils.callJSFile({"File Name": {fullpathj\\moment.js",
                                          "Full Path": true});

    TCS.log.info(moment().format('YYYY\MM\DD-HH:mm:ss.SSS'));

})();

Does anybody has an idea?

thanks

CR

0 Likes
1 Solution

Accepted Solutions
Micro Focus Contributor
Micro Focus Contributor

Re: Vugen Truclient 12.55 vs 12.60: cannot compile moments.js

Jump to solution

Sorry, the code should be:

TCS.log.info(TCS.moment().format('YYYY\MM\DD-HH:mm:ss.SSS'));

3 Replies
Micro Focus Contributor
Micro Focus Contributor

Re: Vugen Truclient 12.55 vs 12.60: cannot compile moments.js

Jump to solution

Hi,

You can try the following workaround:

in moment.js :
//typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
//typeof define === 'function' && define.amd ? define(factory) :
TCS.moment = factory()

in TC script:
TCS.log.info(TCS.moment .format('YYYY\MM\DD-HH:mm:ss.SSS'));

The problem is because the line moment = factory() does not run in the current TC implementation  because exports === 'object' && typeof module !== 'undefined' is true

Thanks,
Michal

0 Likes
Trusted Contributor.. CR Trusted Contributor..
Trusted Contributor..

Re: Vugen Truclient 12.55 vs 12.60: cannot compile moments.js

Jump to solution

HI MIchal,

thanks for the reply, currently it says "cannot read property 'format' of undefined

CR

0 Likes
Micro Focus Contributor
Micro Focus Contributor

Re: Vugen Truclient 12.55 vs 12.60: cannot compile moments.js

Jump to solution

Sorry, the code should be:

TCS.log.info(TCS.moment().format('YYYY\MM\DD-HH:mm:ss.SSS'));

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.