E32: Experience testing “position of the element”

In E28: The position of the element, you wrote a function called position() that accepts a sorted array and a target value and returns the index where the target value is found.

In this experience, we will use Jasmine to test your implementation of this function. We will also use this as an opportunity to make this project comply with our coding standards.

Prerequisites

Prior to starting this WOD, please:

The WOD

Ready? Let’s begin:

  1. Start your timer.

  2. Create a branch of your position repo called “testing-1”. All your work for this WOD will be done in that branch.

  3. Remove IntelliJ files from GitHub and exclude them from future commits to GitHub. A reasonable way to do this is:

    • Add the standard gitignore file
    • Delete the IntelliJ project files locally,
    • Commit and sync these changes.
    • Recreate the project within IntelliJ.
  4. Add the standard .jshintrc file to the project. Enable JSHint on this project in IntelliJ. Fix any JSHint violations.

  5. Add JSDoc comments to function and variable definitions.

  6. Download the Jasmine 2.3.4 standalone distribution if you don’t have a copy already.

    • Copy the lib/ and spec/ directories and the SpecRunner.html file into your project.
    • Delete spec/SpecHelper.js, and rename PlayerSpec.js to PositionSpec.js.
    • Edit SpecRunner.html to load position.js and PositionSpec.js.
  7. Convert the four sample calls in E28 into Jasmine tests.

  8. Check that the tests pass by retrieving the Jasmine page in a browser.

  9. Run JSHint again. Note that new errors are discovered because JSHint is running over the library code. Fix this by creating a custom scope that only run JSHint on position.js and PositionSpec.js. Remove any errors.

  10. When the tests pass and JSHint runs without problems, commit your branch to GitHub.

  11. Check that your branch is on GitHub.

  12. Stop your timer and record your time. Be sure to record it, because you will need your WOD time data when you write your technical essay.

Rx: < 20 min Av: 20-25 min Sd: 25-30 min DNF: 30+ min

Demonstration

Once you’ve finished trying the WOD for the first time, watch me do it:

Standard WOD Caveats

You’ll learn significantly less from watching me solve the WOD if you haven’t attempted the WOD yourself first.

While it’s an achievement to finish the WOD no matter how long it takes, you might experience “diminishing returns” if you work longer than the DNF time. Thus, it is usually strategic to stop working at the DNF time and watch my solution.

After watching my solution, I recommend that you repeat the WOD if you have not achieved at least Av performance. If so, be sure to:

Feel free to keep trying until you make Rx if that’s of interest to you.

Submission Instructions

To be completed by the time and date indicated on the Schedule page.