5 ms·
JS assessment: A test-driven approach to assessing JS skills
- mgkimsal 15y agoGreat idea. I do PHP training, and one of the things I did in some classes is to give failing unit tests to students and have them make them work. I noticed a couple of consistent points when I'd do this: 1. How some students came up with interesting approaches I wouldn't have initially thought up. 2. How many students wouldn't get the tests to pass. They'd do something part way, which would have looked 'good enough' if I'd just described the problem. But when running via a test runner, it failed.
- karl_nerd 15y agoI think those things are super-fun! You always learn something :) Discovered this super-simple "partial" pattern while doing the "functions" part: https://gist.github.com/2375986 https://gist.github.com/2375986
- e2daipi 15y agoIsn't this what is known as currying[1]? [1] http://en.wikipedia.org/wiki/Currying http://en.wikipedia.org/wiki/Currying
- drostie 15y agoI like this idea but I think the design needs to be pretty drastically rethought. Node.js is not really the right medium for this sort of test, although it might function as a first barrier for screening the interested; "you must be able to follow readmes to install software" etc. What I'm more concerned is the idea that this is apparently structured like an automated test. If you used it that way, then here is a function which would pass the first test file: fn = function (a, b) { switch (b) { case 3: return 2; case undefined: return 10; case 2: return '1 3 4'.split(" "); case 10: return [0, 0, 0, 0, 10]; case 'z': return '1 2 z 3 4'.split(" "); default: return '1 2 3 4 a b c'.split(" "); } }; It was built by just looking at the "expect" calls, finding the input to the function and the output from it, and duplicating that output. That's obviously not what you want to test. You really want to say, "you give me an object, and I'm going to generate a couple random test vectors and make sure you do the right thing with those vectors." You shouldn't hardcode the result, but the right algorithms, so that someone else's solutions can be measured against the right way to do things. And then you need to ask people not to modify the right solutions, but to duplicate them.
- speg 15y agoI agree, I also thought it wasn't clear if we were supposed to be writing tests, or code that was to be tested. Instead of modifying the test cases have them fill out a functions file and then run the random tests against those.
- rmurphey3 15y agoMy fear with doing that is that if the functions file is separated from the tests file, then it becomes difficult to see at a glance what the function needs to do in order to make the test pass. That said, I agree that what you're supposed to do could be more clear -- would you care to open an issue so we can discuss it on the repo?
- rmurphey3 15y agoThanks for the great feedback -- it occurred to me that people could simply hard-code the "right" answers into their function. However, if I am using this to assess a candidate, I plan to actually read the code that they write :) And if a person is using this to assess their own skills, I trust that they know that an answer like the one above hasn't taught them anything. Your guess about why I chose something that involves a little bit of setup is right on target, too. Being able to follow the instructions in a readme and get a simple project like this set up is a key skill to have, too.
- ArekDymalski 15y agoNice. Do you plan to put it on the web to make some normalization and standardization of the results? Would be great imho.
- hazz 15y agoIt would great to see this expanded to cover more aspects of JS. It seems like it would be a good set of companion exercises to a tutorial.
- rmurphey3 15y agoI definitely want to add more tests to the set -- if you have ideas for other tests, please open an issue or a pull request on the repo!
- jnicol 15y agoI found the tests really fun. I confess I had to turn to MDN for help with a couple of the questions, and I definitely picked up some new JS knowledge. I agree with drostie that the node requirement is quite a large barrier to entry. A standalone app (no server required) would probably reach a wider audience. I don't think it's a concern that someone might hardcode the answers. These sort of tests are about challenging yourself, and where's the challenge in cheating? For anyone interested, I posted my solutions at http://f6design.com/journal/2012/04/15/test-your-javascript-skills-with-js-assessment/ http://f6design.com/journal/2012/04/15/test-your-javascript-... My 'partial' solution (and probably the rest too!) could be improved I'm sure. Thanks e2daipi for cluing me in about currying.