I’ve been using jasmine at work as a javascript test framework to cover front-end code with all sorts of tests. Recently, on one particular spec, I needed to capture the values returned by a spied upon fonction, without completely interrupting the code execution. As capturing returned values from a spy before continuing code execution is something I couldn’t find in the jasmine framework, I wrote a small integration test that required to use spyOn().andCallFake(), instead of spyOn().andCallThrough(). Here’s my attempt at an implementation.
read more
Latest fun tiny project: creating a small mastermind game in javascript in less than 1k for http://js1k.com/.
Play here: http://mastermind.ekynoxe.com/ or download it from github and run it offline!
Rules are simple:
Guess by submitting with your keyboard numbers from 0-9
After pressing 4 digits the guess is automatically submitted
The result shows symbols:
* no symbol means no digit is in the code to guess
* a ‘-’ means one of the digits is in the code to guess, but not at the correct place
* a ‘+’ means one of the digits is in the code to guess, AND at the correct place
If a digit exists twice in the code to guess, symbols do not represent it, you will have
to get it by yourself!
An alert is displayed when the code is found, and the game reset