New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Testing Guide #3862

phillipskevin opened this Issue Jan 25, 2018 · 1 comment


None yet
1 participant

phillipskevin commented Jan 25, 2018

We propose a guide that will teach people how to test CanJS applications.

This was discussed on a recent live stream (9:04).

This guide will try to explain how to test each piece of your application, including:


This guide will go over the basics of testing ViewModels, but also explain more complex topics like how/when to create asynchronous tests.


This will explain how to tests components with and without using the DOM. It will also include Make it easier to test Components.


Testing routing can be difficult to do without accidentally changing the real URL. This piece of the guide will focus on using param/deparam for testing so that real routing does not occur.


This will focus on setting up fixtures and generating test data. Testing set algebras will be added if/once canjs/can-query-logic#1 is complete.

Functional tests

The guide will also introduce functional testing and try to explain when it is a good idea to create functional tests.


This comment has been minimized.


phillipskevin commented Sep 5, 2018

More Detailed Outline:

1. Testing ViewModels
  a. Basic setup
  b. Overriding getters - using lastSet to "override" the return value of a getter to test properties derived from it
  c. Async properties
2. Testing Componens
  a. Basic setup
  b. ViewModel - show using `Component.ViewModel` then link to (1).
  c. Events - using bindings -> just call the functions. Using `listenTo` in a `value` or `connectedCallback` -> dispatch events.
  d. connectedCallback - example of third-party integration and how to manually call `connectedCallback` or actually insert in the page.
3. Testing Routing
  a. Basic setup
  b. Data - `` -> show creating `routeData` property and how to use `RouteMock` to verify URL changes without changing the real URL.
  c. Component - `componentToShow` pattern and how to test it independently.
  d. Component viewModel -> `componentToShowViewModelData` (but something shorted) and testing `value.from`/`value.bind`/etc properties using Reflect.
4. Testing Models
  a. Basic setup - create a fixture, test that `getList`,etc return correct data.
  b. Generating test data - using `` and `queryLogic`.
  c. Testing `QueryLogic` - using `filterMembers` to test schema. Using `isMember` to test custom `toQuery`/`toParams`
5. Integration Testing
  a. When should you do it?
  b. Basic setup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment