Simple Javascript testing Chai.
- Testing to confirm a movie title is formatted in the proper Title Case.
- Node.js
- Chai
- Clone repo
- Install dependencies
- In terminal, move into the chai-tests directory and run tests on textUtilities.js
node textUtilities.js
- Chai will show a waiting prompt if all tests pass or an error message
Chai throws an assertion error when the movie title is not in the proper title case.
Chai shows a waiting console prompt when tests are correct
- Using Behavior Driven Development (BDD) style with the Chai expect method
- Chai is a BDD/TDD assertion library for node and the browser. It can pair with any javascript testing framework. ChaiJS.com
- Writing tests with Chai's expect method
- The goal is to create a function to evaluate a move title and make sure the words are capitalized
- First write a test to confirm the movie title is a string. Then write the code and check it with the test
- Then break the process down into small steps, check one letter, then check one word
- Write a test to check if the first letter in the word is capitalized
- Then write a function and a step to capitalize the a letter
- Then the first letter of a word.
- Build logic for changing one word then put it into a loop:
- Split each word in the string
- Rejoin each word back into the title
- Review info in tutorial
- Treehouse Tutorial: Part 1: Introducing Unit Testing
- Treehouse Tutorial: Javascript Unit Testing
- Google Testing Blog
- Popular Tests Tools, Languages and Platforms
- ChaiJS.com
- Chai Installation Instructions
- Chai Assertion Styles
- Using Title Case
- Steven Anderson Blog: Writing Great Unit Tests
- JavaScript String toUpperCase() Method
- JavaScript String substring() Method
- JavaScript String split() Method
- JavaScript Array join() Method
- Array.prototype.map()