ledger-scripts | Scripts I use with ledger
kandi X-RAY | ledger-scripts Summary
kandi X-RAY | ledger-scripts Summary
Scripts I use with ledger
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of ledger-scripts
ledger-scripts Key Features
ledger-scripts Examples and Code Snippets
Community Discussions
Trending Discussions on ledger-scripts
QUESTION
I recently learned about clasp, and became excited about the possibility of using TDD to edit my Google Apps Scripts (GAS) locally.
NOTE: there might be a way to write tests using the existing GAS editor, but I'd prefer to use a modern editor if at all possible :)
clasp works great, but I cannot figure out how to mock dependencies for unit tests (primarily via jest, though I'm happy to use any tool that works)
- I got farthest by using the gas-local package, and was able to mock a single dependency within a test
- However I could not find a way to mock multiple dependencies in a single test/call, and so I created this issue
- I am a javascript novice, and probably missed something important while researching this problem :)
- Despite installing @types/google-apps-script, I am unclear on how to "require" or "import" Google Apps Script modules whether using ES5 or ES2015 syntax, respectively--see below for an illustration of this.
Although there is a similar SO question on unit testing here, most of the content/comments appear to be from the pre-clasp era, and I was unable to arrive at a solution while following up the remaining leads. (Granted, it's very possible my untrained eye missed something!).
Attempts Using gas-localAs I mentioned above, I created an issue (see link above) after trying to mock multiple dependencies while using gas-local. My configuration was similar to the jest.mock
test I describe below, though it's worth noting the following differences:
- I used ES5 syntax for the
gas-local
tests - My package configuration was probably slightly different
ANSWER
Answered 2020-Aug-15 at 20:31Note: the scope of your question is broad and may require clarification.
clasp works great, but I cannot figure out how to mock dependencies for unit tests (primarily via jest, though I'm happy to use any tool that works)
You don't need Jest or any particular testing framework to mock the global Apps Script objects.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ledger-scripts
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page