
Define a test as code that validates JavaScript and Node applications, moving from manual testing to automated spec-based tests that run to confirm expected results and catch changes before production.
Explore how assertions validate code by comparing actual results with expected values using the assert module in node.js, including equal, not equal, deep equal, and throws.
Explore how a test runner executes mocha tests, structures them with describe and it, and displays clear output, using npm scripts and a dedicated test folder.
Explore testing parse and stringify functions by building mocha tests that convert query strings to objects and objects to valid query strings, using require, assert, and deep equal checks.
Learn to test asynchronous functions with a mock database and user model, using done callbacks, returning promises, and async/await, with examples like find user by email.
Learn how to test rejected promises in node applications by asserting errors when a user email is not found, using return-based tests, and verifying that promises reject with specific messages.
Discover test coverage reporting with NYC to reveal what your JavaScript and Node.js code has been tested, showing statements, functions, branches, and lines, and highlighting uncovered areas.
Migrate your tests to Jest by installing Jest, configuring npm test, and replacing assert modules with expect, while using --coverage to generate test scores and cover success and rejection cases.
Boot a full stack JavaScript project with a generator, configure Express and MongoDB, set up environment variables and a JWT secret, and test user registration and authentication workflows.
Explore testing a mongoose user model with a pre-save hook that hashes the password before saving, including setting up a test database and Jest environment.
Learn to speed up tests by mocking the mail package with jest, replacing the email sender with a mock class, and ensuring mongoose connections are closed after tests.
Understand setup and teardown in javascript tests with before, before all, and after all hooks to manage a mongoose database connection, run asynchronous tests, and reduce duplication within describe blocks.
Learn how to test instance methods in a node application by refactoring with before and before all hooks, generate and verify JWTs using jsonwebtoken and a secret.
Test a login validator middleware in an Express app using Jest to verify validation against an email and password schema, and ensure next is called on success.
Test validation failures by mocking a request and a response, using a chainable status and json in a mock response, and spying to verify correct calls.
Test the authentication middleware by validating JWT payloads, checking database for users, and verifying access control with success and failure scenarios.
Refactor tests by moving utilities into a test/mutuals folder and exporting a default response class, then configure jest to ignore non-test files and manage mongoose connections only when needed.
Create integration tests for the registration process using supertest against the API register endpoint, isolate the app from the listener, and verify a 200 response with a valid JWT.
Test failed registrations by simulating a duplicate user in the database, calling the registration API endpoint, and asserting a validation error response.
Explore integration tests for the e-mail confirmation process, including the validator, token flow, and controller, and learn to verify database updates for both invalid and successful confirmations.
Learn to set up Cypress for end-to-end testing, install and configure Cypress, and run tests in a real browser with integration tests that visit pages and assert behavior.
Demonstrate Cypress tests for the home page by visiting, selecting elements with CSS selectors, and asserting the title text, then verify sign-in and register navigation.
Test the login flow by mocking the server with Cypress, intercepting the login API, and using fixtures to simulate responses, then verify the user name and logout behavior.
When I started learning how to test, everything looked so easy.
Assert 2 + 2 = 4 ?
Sure, piece of cake. But when I was faced with a real world application, this was terrifying. I couldn't catch up at my job. It was depressing. I didn't understand what mocking was. Neither did I understand topics like stubbing or spying.
That's why I created this course. You are going to start from scratch, understanding exactly what a test is, what an assertion is, what errors are, and then we'll move on to more basic topics like:
Unit testing
Test runners
Assertion libraries
Test suites and organising tests
Running tests
To master these concepts, we'll write unit tests for real world functions, and understand exactly how testing feels when working on a real world project.
We'll have a full-stack real-world advanced javascript application, build with the latest features of Javascript, and we'll clone this project, and write tests for it from scratch.
There will be plenty of assignments and code reviews, to make sure you understand exactly what is being thought in the course.
After our feet are wet , and we can write basic tests, and after solving multiple exercises, we'll move on to a more real world approach, covering advanced topics like:
Feature / integration testing
Mocking
Spying & stubbing
Asynchronous tests
Database testing
End to end testing
We'll then dive into TEST DRIVEN JAVASCRIPT DEVELOPMENT, understanding the RED, GREEN, REFACTOR TESTING CYCLE, and how to apply this into our projects to build more robust and bug free applications.
So what are you waiting for ? Are you ready to become an advanced javascript engineer? Enrol now and let's get started !