Record how a method was accessed, including how many times and with what arguments using Sinon.JS spies.
- [Instructor] So far we've been specifying functionality.…What if we just want to observe?…Spies are the solution.…Sinon Spies can be used to record information…about function calls.…Similar to stubs, spies can be anonymous…if you don't need to test behavior.…More commonly, spies can wrap existing methods.…The existing method will continue to behave…exactly like it did before.…It will also record how the method is being accessed…like how many times and with what arguments.…
How are we going to use spies in our application?…It'd be useful to check how the validator was called…when creating a reservation.…The validator should only be called once.…When called through create, it should be called…with a transformed reservation.…Let's add a spy to our test.…Switch over to Atom.…Make sure that test unit lib reservations is open.…We're going to need to require Sinon Chai…for a few new assertions.…Under should, const sinonChai equals require sinon-chai.…
Then after the requires, we'll tile chai…to use the plugin sinonChai.…
- What is code quality?
- Testing and code quality fundamentals
- Coding conventions and standards
- Creating and enforcing coding standards
- Unit, integration, and functional testing
- Test-driven development test specificatons
- Behavior-driven development test specifications
- Finding errors with linting
- Extending an ESLint shareable config
- Validating correctness with unit testing
- Replacing and inspecting with stubs, spies, and mocks
- Code coverage and why it matters
- Coverage with continuous integration
Skill Level Intermediate
Node.js: Build Your First Microservicewith Daniel Khan2h 9m Intermediate
Building APIs Using Hapi in Node.jswith Kirsten Hunter2h 23m Intermediate
1. Testing and Code Quality Fundamentals
2. Finding Errors with Linting
3. Validating Correctness with Unit Testing
4. Replacing and Inspecting with Stubs, Spies, and Mocks
5. Reporting on Your Entire Codebase
Where to go from here?3m 46s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.