-
Notifications
You must be signed in to change notification settings - Fork 192
100% coverage #79
Comments
|
|
EDIT related issue outmoded/hapi-contrib#14 |
The response is in internals so you don't create the object on every request. It's a small optimization. |
I'm a bit stuck with the logic of testing when no arguments are given to init. Specifically I am curious the best practice on what init should return. If init does not return the server then there is no way to shut it down in testing without using something for spying. For right now I have opted to return the server, it is gross but hopefully it will work for now |
Closes outmoded#79 This introduces basic testing and code coverage at 94.74% There is definitely still some weirdness with testing error handling when Hoek is asserting. I'm still not sure the best way to teardown the server if no callback is given.
Closes outmoded#79 This introduces basic testing and code coverage at 94.74% There is definitely still some weirdness with testing error handling when Hoek is asserting. I'm still not sure the best way to teardown the server if no callback is given.
Closes outmoded#79 This introduces basic testing and code coverage at 94.74% There is definitely still some weirdness with testing error handling when Hoek is asserting. I'm still not sure the best way to teardown the server if no callback is given.
Closes outmoded#79 This introduces basic testing and code coverage at 94.74% There is definitely still some weirdness with testing error handling when Hoek is asserting. I'm still not sure the best way to teardown the server if no callback is given.
@thealphanerd did you notice the steps above to modify the |
Indeed. You specifically state I think I managed to figure out how to get that to work as expected with coverage. The only thing I'm stuck on now is figuring out how to test specific error states that we will be executing the callback from. For example how do I write a test that guarantees the plugin will load with an error. |
It is worth mentioning that the solution I found was returning the server object when no callback is provided. What confused me specifically was how to properly stop the server if not callback was provided |
I have changed the assignment (step 7 and 8) to avoid the problem you hit. Sorry about that. |
@hueniverse I can see the optimization but does it weigh up against less readability? Also last thoughts on the makefile? |
@hueniverse one more quick clarification. Do we want to call |
Leave |
What about the travis integration? Do we need to set that up? I have added the travis.yml file, but do I need to configure my project in Travis to verify that I have automated this properly? |
the .travis file is all you need! On Mar 25, 2015, at 10:37 AM, John Townsend notifications@github.com wrote:
|
Question and Solution Regarding Item 7: Modified original post and replaced it with the below observations. Originally, I was not clear about why or how to face the above item7 issue. When writing error handling code either you pass the error up the call back chain Item7 just wants us to make init() "throw safe". With throw safe code, if a module does not load properly the error will not shut the whole application down. Hopefully, this will help someone when addressing item7 in the assignment list. If you want to see a good example of this check out @thealphanerd's assignment3 PR ./lib/index.js. If I made a mistake above, please correct my observations. |
Community, I am bit more than stuck starting from point 6, I could use some help to get going. |
To @zoe-1's point, the code in index.js and version.js should not be throwing any errors, with Hoek, but instead should be sending any errors back to the original caller - which would be either start.js or in the test code. |
Is there a way to have the linter display the filenames where linting errors are found? Mine only shows line numbers but no filenames. |
@mikejerome linter does show both filename and line numbers, see below example output of linter Linting results:
lib/index.js:
Line 15: semi - Missing semicolon.
lib/version.js:
Line 15: no-trailing-spaces - Trailing spaces not allowed. |
Hmmm I'm using solarized terminal. The filenames must be the same color as my background or something. I verified that they are there by copy-pasting but they are invisible in my terminal. Edit: I've confirmed it looks like an issue with my terminal theme the filenames are there. Thanks. |
General comments:
Also, if others are leaving comments on your code, you should either reply or address their suggestions. This experiment works by learning sideways, not just top to bottom. I have seen a lot of great comments from peers, so please respect their time and use it to learn. If I see you ignoring useful comments from others, I am not going to bother adding my own comments. |
👍 |
thanks for taking the time! |
Thanks for the feedback :-) |
|
lab docs show how to include the parallel option. lab.test('returns true when 1 + 1 equals 2', { parallel: false }, function (done) { Code.expect(1+1).to.equal(2); done(); }); source: https://github.com/hapijs/lab I believe monkey patching would be where we changed the default values
|
Is that just the Makefile used in the hapi project and/or the npm scripts? |
@tielur I think it refers to the names you give
|
@gyaresu ahh ok that makes sense. Thanks! |
@tielur I just grabbed your code to have a look and the |
@hueniverse commented: Some of you missed the change in the assignment to make both arguments in init() required. I am assuming he wants the parameters in init() to be validated. How are we to interpret this? |
The original assignment had the port as optional which meant you had to check if the first argument was a number or a function. This was removed but not everyone got the memo. |
Ok. got it. |
@gyaresu it's the |
@tielur Sweet. Thanks. |
I have a error that I cannot solve.,
and changed it to :
but now on every test I see a error message that port must be a string, a number. My code can be found here : https://github.com/roelof1967/hueniversity |
@roelof1967 you have tests that are omitting the port |
Thanks, it worked now without any problem. A new PR is submitted already |
@hueniverse is it beneficial to add |
@AdriVanHoudt Nah. |
@hueniverse could you go into why you choose that PR to merge? Also there is now no way for me t run the tests on my windows 😐 |
You can install make on Windows, I use https://github.com/lukesampson/scoop which is very good for Windows users. On 19 Apr 2015 10:00 am, AdriVanHoudt notifications@github.com wrote: @hueniversehttps://github.com/hueniverse could you go into why you choose that PR to merge? Also there is now no way for me t run the tests on my windows [:neutral_face:] — |
So are we creating a Makefile? Also, when you say "Add the standard hapi.js Makefile" please point to documentation on what that "standard hapi.js Makefile" is and how it should be constructed. Too many assumptions on what we know what you're talking about. |
@johnmank Below is the answer to your makefile question. As referenced in this assignments post: |
Things are getting a bit more interesting...
It's time to add tests, verify coverage, confirm style, and automate all of this with CI. We will be using the lab module to perform all these tasks and automate it with travis.
.travis.yml
file, testing our project on node 0.10, 0.12, and io.js (latest).version.js
andindex.js
, each testing the corresponding file under/lib
.package.json
file to include the tests, as well as the dev dependency to lab.version.js
.init()
method to accept a port and a callback. Use the callback to return when the function completes or errors. Theinit()
callback should return any error state as well as a reference to the newly created server. This will allow us to later stop the server when we test it.init()
and move the invocation to a newstart.js
file (which will call theinit()
function with the8000
port and a callback the outputs the information to the console when started). Change thepackage.json
file to use thestart.js
file as the starting place. This file will not be covered by tests.init()
function inindex.js
.Everything up to (10) should be pretty straight forward. If you are not sure on how to use lab and code, look at other hapi.js modules like hoek, qs, items, and boom (e.g. simple modules) to copy their test scripts and setup.
Getting 100% coverage can be tricky sometimes so if you are not sure, get as much coverage as you can, and comment on the lines in your pull request where you are having a hard time reaching and someone will give you a clue.
Remember to properly
stop()
your servers when calling theinit()
method in each test.For now, avoid using any of the
before()
andafter()
lab features.As always, ask for help and help others!
Due: 4/4
The text was updated successfully, but these errors were encountered: