April 2020
Intermediate to advanced
292 pages
6h 50m
English
Application tests are simpler as well. Generally, they just write a message and then respond. Here’s a test used as part of registering users:
| | test('Issues the registration command when user submits good data ', t => { |
| ① | const userId = uuid() |
| | const attributes = { |
| | id: userId, |
| | email: 'finally@example.com', |
| | password: 'adsfasdf' |
| | } |
| | |
| | |
| | |
| | |
| | |
| ② | return supertest(app) |
| | .post('/register') |
| | .type('form') |
| | .send(attributes) |
| | .expect(301) |
| | .then(res => { |
| | t.assert(res.headers.location.includes('registration-complete')) |
| | }) |
| ③ | .then(() => |
| | config.messageStore |
| | .read(`identity:command-${userId}`) |
| |
Read now
Unlock full access