From 9da1a88e7409143dfe8cb03aec869f3c5aac7214 Mon Sep 17 00:00:00 2001 From: David Mehren Date: Tue, 22 Sep 2020 18:30:22 +0200 Subject: [PATCH] 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 --- test/public-api/notes.e2e-spec.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/public-api/notes.e2e-spec.ts b/test/public-api/notes.e2e-spec.ts index a75843863..fad8db385 100644 --- a/test/public-api/notes.e2e-spec.ts +++ b/test/public-api/notes.e2e-spec.ts @@ -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); });