Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For those who are interested, here's my solution to qualification task.
I chose to implement the Basic output format. I started by writing my test suite. For each keyword, I created at least one passing and failing test based on what result I expected from that keyword. I then went through and updated each of the applicator keywords to collect errors and add them to the Output object that was being returned. That was enough to get my tests passing, but I noticed that there was a lot of duplication in the code I just added to the keyword handlers. In working to eliminate the duplication, I was able to move all of the error collection and output generation into the
validateSchema
function. I was pretty happy with that because it means all of the output code is in one place and there's no duplication. It also allows the keyword handlers to be able to just return a simple boolean instead of an output unit, which I was also very happy about.Because this solution required some refactoring, it may be hard follow what I did by looking at the PR as a whole. You may find it easier to just look at the last commit to see the actual solution. Other than refactoring to return a boolean instead of an Output object, the only changes to the keyword handlers were to pass the errors array through. All the actual logic is in the
validateSchema
function.This is an implementation of the Basic output format, but this approach works for the Detailed output format as well. As an exercise to make sure you understand, try to figure out the small change it would take to change this to an implementation the Detailed output format.