- Overview
- Installation
- Actions
- Tasks
- Middleware
- Satellites
- Cluster
- Cache
- Chat
- Development Mode
- File System
- Events
- WebSocket
- TCP
- HTTP
- Security
- Validation
- Logging
- Commands
- Testing
Models
- Introduction
- Data Types and Attributes
- Instance and Class Methods
- Validations
- Associations
- Model Configuration
- Queries
Testing
Introduction
Stellar comes with a useful tool to improve the write of your unit testes, as well speed up their execution.
Stellar is built with testing in mind. In fact, support for testing with Mocha JS is included out of the box and the command line tool already contains a command to easily run your application tests. The actions and the framework it self was designed to improve the testing experience.
Environment
When running tests via stellar test
command, Stellar will automatically set the configuration environment to testing. Stellar also automatically configures, by default, the cache to use an in memory system, as well the database system, meaning no cache or data entry will be persisted while testing. This also improves significantly the tests speed.
You are free to define other testing environment configuration values as necessary. The testing environment variables may be configured in the /config
folder of your module or application. For that you must use the development
space, as you can see bellow:
'use strict' |
Creating & Running Tests
To create a new test case, use the make test
command:
# create a test in the tests directory |
Once the test has been generated, you may define test methods as you normally would using Mocha. To run your tests, simply execute the stellar test
command from your terminal:
// var to store the Stellar's API object |