Conversation
- Added instructions for running in README - Added tests for calls to console.log in 1-writers and 8-reading-list - Clarified 6-people-I-know to distinguish friends and colleagues, rather than my friends and their friends - Added functions to be callable from tests where relevant - Did not cover 4-water-bottle, 7-recipes or 11-choose-your-own-adventure
|
I notice I'm missing the license. I'll get round to that. I was wondering what the best approach might be for exercise 4-water-bottle. And I was wondering whether 7 and 11 were worth trying to create tests for. 7 might be a bit brittle depending on using \n in their console.logs (though I guess we say one console.log per line?) 11... I wonder if the source could be designed to run in two modes, based on whether the test function is defined (if yes we are in jest, if no we are in node?) |
|
@SallyMcGrath What do you think of consistently having the README instructions for running the tests to have this format? |
illicitonion
left a comment
There was a problem hiding this comment.
Looks good, thanks!
I was wondering what the best approach might be for exercise 4-water-bottle.
I think converting the existing "Do 100 things in a row and assert they all worked" into targeted unit tests which happen to share one global object (ick, but... It only has one field of state, and not teaching constructors feels worthwhile a at this point - at least JS is single-threaded!), where we force preconditions... I'm thinking of 10-ish tests along the lines of:
test("pouring full water bottle doesn't over-fill it", () => {
bottle.volume = 100;
bottle.pour();
expect(bottle.volume).toEqual(100);
});
And I was wondering whether 7 [...] worth trying to create tests for.
I probably wouldn't bother... If we do test it, I would lean towards asserting on the structure, rather than the logs - something like:
- Assert that the
recipesobject contains at least 5 properties - Assert that for each property it's an object containing a title string, a servings number, and a non-empty array of ingredient strings
If we were teaching them about classes/constructors, we could have a nice toString method we could test, but I suspect that's more hassle than it's worth.
11... I wonder if the source could be designed to run in two modes, based on whether the test function is defined (if yes we are in jest, if no we are in node?)
Could be interesting!
|
Notes to self/what I'll follow up on in this PR
Followup PR
Different Repos/tickets
|
|
README: npm test is missing |
View rendered README.md