Skip to content

API accepts a JSON payload (Vitest)

### ✅ API accepts a JSON payload
- **Given** the client has the following JSON payload
**Payload**
```json
{
"email": "[email protected]",
"password": "secret",
"rememberMe": true
}
```
- **When** the client sends the request
- **Then** the response status should be 200
- **And** the response body should include "token"
import { story } from 'executable-stories-vitest';
import { describe, it } from 'vitest';
describe('API', () => {
it('API accepts a JSON payload', ({ task }) => {
story.init(task);
story.given('the client has the following JSON payload');
story.json({
label: 'Payload',
value: {
password: 'secret',
rememberMe: true,
},
});
story.when('the client sends the request');
story.then('the response status should be 200');
story.then('the response body should include "token"');
});
});

From apps/vitest-example/src/replicate.story.test.ts.