« first day (502 days earlier)      last day (867 days later) » 

9:47 AM
0
Q: I want a mock function written in Typescript and Jest for Logger.log method of Google Apps Script

YAMADA MasahiroMy Goal and Problem I want to test a Google Apps Script code written in Typescript using Jest on my local laptop. The code has a method call, Logger.log, which is specific to GAS, and I have to give the tester a mock function for. Codes and Result Code to be Tested ./src/code.ts export function h...

 
9:59 AM
@TheMaster yeah, and paired with modules, it would be so much nicer (imagine GAS and Node.js/Deno codebases mapping directly to each other)
@TheMaster I will admit it is not blocking, as in "do not do that" rather than "this is the worst idea of all time". What I do not like is that it makes the global scope stateful which often leads to bugs. I vividly remember a client that was also a beginner programmer that assumed that files do not share scope (as they would not if only JS itself had proper modules)
@TheMaster that is true, actively discouraged (although I try to circumvent that whenever possible - in my experience, when people choose GAS platform, performance is the last thing on their mind)
actually, the direct call to cache in the global scope is overslimplification - it would normally be called inside the function scope of the main function (or whatever is the caller depending on the context)
as for the introduction of two vars - as I mentioned, I do not consider DRY to be about absolute number of LoC/variables but rather a principle that dictates repeating operations to be abstracted into reusable chunks. Of course, at some point, we have to introduce some globals, normally when declaring functions - normally, this would be function declarations, it is just my pref. to create named arrow functions instead
 

« first day (502 days earlier)      last day (867 days later) »