lambda-tester: verifying callbacks

Their (see post from last night) documentation is really clear with good examples that you can easily work from.

So I’ve now moved on to trivial callback verification. Some screenshots as I inched forward…

npm install chai -g
npm install chai --savedev
npm init
mocha

 

 

Gist.

Advertisements

AWS Lambda/Node: starting unit testing

After some evenings of googling [AWS Lambda/Node/unit test framework] and playing with the results, I think I am pretty much up and running thanks to this person or persons…

and their excellent lambda-tester framework here and here.

For me, they have really abstracted things away well, and left very few moving parts behind to trip you up.  Thanks! 🙂

Important points:

  • Node in AWS Lambda works on a latest version of 6.10.* (I’m using 6.10.3, on Windows, FWIW). There are 2 other (earlier) supported versions – I’d stick with 6.10.
  • Sucking eggs: unless you are already clued up on AWS Lambda and Node (I’m using it for Alexa Skills, and I am a noob at this), do the Simplest Thing Possible to start with. On the Amazon side, I suggest that means the HelloWorld blueprint below. Then play with the first callback argument being null (success), and not null (failure), and see it come through when you run mocha. Point being ref Mocha: I think the lambda-tester help is pretty comprehensive for getting just enough knowledge on these supporting packages. Ping me if you want some help on this. I’m not many steps ahead of you, believe me :-). Of course, Hello World gives you nothing useful of itself. But this exercise is all about seeing the round trip working from a test to a function under test, both for a success, and for a failure.

Node: basic testing

Gist.

AWS Lambda testing: dump of notes so far

Lessons: node 6.10.3. Don’t try the current version – it won’t work.
In my js/noob world, Lambda-tester is looking the simplest way so far to test AWS Lambdas. I’m not quite there yet, but will return to this very soon.

https://www.npmjs.com/package/lambda-tester

  Id CommandLine
 -- -----------
 1 node -v
 2 npm -v
 3 function prompt(){}
 6 pwd
 7 cd C:\Github\Alexa\MagContact\src\PackageSet\test
 8 pwd
 9 ls
 10 mocha
 11 cd ..
 12 pwd
 13 mocha
 15 npm install lambda-tester --save-dev
 16 npm install nonsense --save-dev
 17 npm install nonsensex --save-dev
 18 npm install lambda-tester --save-dev
 19 ls
 20 mocha
 21 npm install mocha -g
 23 mocha
 24 Get-History

6.10.3

http://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html

https://nodejs.org/en/blog/release/v6.10.3/

Windows 32-bit Installer: https://nodejs.org/dist/v6.10.3/node-v6.10.3-x86.msi
Windows 64-bit Installer: https://nodejs.org/dist/v6.10.3/node-v6.10.3-x64.msi
Windows 32-bit Binary: https://nodejs.org/dist/v6.10.3/win-x86/node.exe
Windows 64-bit Binary: https://nodejs.org/dist/v6.10.3/win-x64/node.exe

https://nodejs.org/dist/v6.10.3/node-v6.10.3-x64.msi

https://github.com/mapbox/lambda-cfn/issues/54

 

 

Git: move or rename a file or folder

as


If you want to change the case of a file or folder, but not rename it, then you need to do this in 2 steps. E.g. given a folder [Test], that I want to change to [test], then do this:

git mv Test temp

git mv temp test

Github Desktop, for example, will interpret that as a single rename (Test -> test), and you can commit without further ado. I could not find a single step way to do this rename.

 

JavaScript and ES6: looping

As I am pretty much a noob at JavaScript (Alexa-related posts passim), I thought makes sense to incorporate the use of ES6 from the start. So I need to loop through an array… does ES6 bring anything new to the table on that? Googled that, found this.

The author and the series looks a good place to consult for ES6, so will return to his posts.

And for looping, this is the answer:

for (var value of myArray) {
 console.log(value);
}