# Unit test
Ts.ED support officially two unit test frameworks: Jest and Mocha. It's also possible to use your preferred frameworks. Your feedback are welcome
Since Platform Api is available, Ts.ED provides two way to test your code. If you use , look on the Legacy tab. If you use Platform API, look on v5.56.0+ tab.
# Async / Await
Testing asynchronous method is also possible using
# Mock dependencies
PlatformTest API provides an
invoke method to create a new instance of your component with mocked dependencies.
PlatformTest.invoke() executes automatically the
# Test your Rest API
To test your API, I recommend you to use the
To install supertest just run these commands:
If you use the PlatformTest, you'll probably get an error when you'll run the unit test:
Platform type is not specified. Have you added at least `import @tsed/platform-express` (or equivalent) on your Server.ts ?
To solve it, just add the
import @tsed/platform-express on your
Server.ts. PlatformTest need this import to know on which Platform
your server must be executed for integration test.
# Testing session
To install session with Ts.ED see our tutorial.
- Session & cookies
- Serve static files
- Throw HTTP Exceptions
- Customize 404
- Injection scopes
- Custom providers
- Custom endpoint decorator