Files
cats.gateway.e2e-spec.ts
What you'll learn
- Start a Nest application with its gateways in a test, listening on a port, and close it after each test
- Connect socket.io clients from a test, listening before connecting so nothing sent during the handshake is missed
- Assert on acknowledgements with emitWithAck(), and on what every client received, including the ones that should have received nothing
- Know that a gateway test must wait for events in flight before asserting, and why asserting nothing arrived is a real assertion
Press Run tests to start the app. Its log appears here.Tests
- test/cats.gateway.e2e-spec.tsrun to see its tests
Bugs your tests must catch
Each of these replaces one file with a buggy version and runs your tests again. A bug is caught when at least one test fails against it. Tests that pass whatever the code does are not tests.
- a new cat is announced to its sender as wellcats/cats.gateway.ts
- an adopted cat can be adopted againcats/cats.gateway.ts
- nobody hears who leftcats/cats.gateway.ts
- a newcomer hears their own arrivalcats/cats.gateway.ts