Note E2E tests: Set a non-JSON content-type to avoid Nest trying to parse markdown to JSON.

Nest automatically tries to parse incoming requests with application/json as content-type and responds with HTTP 400 if the parsing fails. As our test-note-content is not valid JSON, we need to set another content-type.

Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
David Mehren 2020-09-22 18:30:22 +02:00
parent c43448624b
commit cccd52d1b0
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3

View file

@ -37,6 +37,7 @@ describe('Notes', () => {
const newNote = 'This is a test note.';
const response = await request(app.getHttpServer())
.post('/notes')
.set('Content-Type', 'text/markdown')
.send(newNote)
.expect('Content-Type', /json/)
.expect(201);
@ -60,6 +61,7 @@ describe('Notes', () => {
const newNote = 'This is a test note.';
const response = await request(app.getHttpServer())
.post('/notes/test2')
.set('Content-Type', 'text/markdown')
.send(newNote)
.expect('Content-Type', /json/)
.expect(201);
@ -82,6 +84,7 @@ describe('Notes', () => {
notesService.createNote('This is a test note.', 'test4');
await request(app.getHttpServer())
.put('/notes/test4')
.set('Content-Type', 'text/markdown')
.send('New note text')
.expect(200);
return expect(
@ -93,6 +96,7 @@ describe('Notes', () => {
// TODO
return request(app.getHttpServer())
.post('/notes/test5/metadata')
.set('Content-Type', 'text/markdown')
.expect(200);
});