> [email protected] pretest
> jest --clearCache npm run lint:fix && npm run build && npm run postbuild
Cleared /tmp/jest_0
> [email protected] build
> tsc
> [email protected] postbuild
> ncp ./src/openapi.yaml ./dist/openapi.yaml
> [email protected] postbuild
> ncp ./src/openapi.yaml ./dist/openapi.yaml
> [email protected] test
> cross-env NODE_ENV=test jest --runInBand --no-cache --detectOpenHandles --forceExit --coverage
FAIL src/server.test.ts
todo
GET /todo
β responds with json (41 ms)
POST /todo
β responds with the posted todo (24 ms)
β responds with the error (7 ms)
β responds with the error when title has over 1000k (12 ms)
β responds with the error when Todo has extra properties (8 ms)
PUT /todo/:id
β updates the todo with the given id (6 ms)
β responds with the error when malformed Todo (9 ms)
β responds with the error when id not found (7 ms)
β responds with the error when Todo has extra properties (13 ms)
β responds with the error when title has over 1000k (9 ms)
DELETE /todo/:id
β deletes the todo with the given id (7 ms)
β responds with the error when malformed id (8 ms)
β responds with the error when id not found (6 ms)
β todo βΊ GET /todo βΊ responds with json
expect(received).toBe(expected) // Object.is equality
Expected: 200
Received: 500
20 | it('responds with json', async () => {
21 | const response = await request(app).get('/todo');
> 22 | expect(response.statusCode).toBe(StatusCodes.OK);
| ^
23 | expect(response.body).toEqual(
24 | expect.arrayContaining([
25 | expect.objectContaining({
at src/server.test.ts:22:35
at fulfilled (src/server.test.ts:5:58)
β todo βΊ POST /todo βΊ responds with the posted todo
expect(received).toEqual(expected) // deep equality
- Expected - 4
+ Received + 1
- ObjectContaining {
- "id": Any<Number>,
- "title": "Test Todo",
- }
+ Object {}
37 | const response = await request(app).post('/todo').send(todo);
38 |
> 39 | expect(response.body).toEqual(
| ^
40 | expect.objectContaining({
41 | id: expect.any(Number),
42 | title: 'Test Todo',
at src/server.test.ts:39:29
at fulfilled (src/server.test.ts:5:58)
β todo βΊ POST /todo βΊ responds with the error
expect(received).toEqual(expected) // deep equality
- Expected - 3
+ Received + 1
- ObjectContaining {
- "error": "Invalid todo",
- }
+ Object {}
49 | const response = await request(app).post('/todo').send(todo);
50 |
> 51 | expect(response.body).toEqual(
| ^
52 | expect.objectContaining(INVALID_TODO_ERROR)
53 | );
54 | expect(response.statusCode).toBe(StatusCodes.BAD_REQUEST);
at src/server.test.ts:51:29
at fulfilled (src/server.test.ts:5:58)
β todo βΊ POST /todo βΊ responds with the error when title has over 1000k
expect(received).toEqual(expected) // deep equality
- Expected - 3
+ Received + 1
- ObjectContaining {
- "error": "Invalid todo",
- }
+ Object {}
58 | const response = await request(app).post('/todo').send(todo);
59 |
> 60 | expect(response.body).toEqual(
| ^
61 | expect.objectContaining(INVALID_TODO_ERROR)
62 | );
63 | expect(response.statusCode).toBe(StatusCodes.BAD_REQUEST);
at src/server.test.ts:60:29
at fulfilled (src/server.test.ts:5:58)
β todo βΊ POST /todo βΊ responds with the error when Todo has extra properties
expect(received).toEqual(expected) // deep equality
- Expected - 3
+ Received + 1
- ObjectContaining {
- "error": "Invalid todo",
- }
+ Object {}
68 | const response = await request(app).post('/todo').send(todo);
69 |
> 70 | expect(response.body).toEqual(
| ^
71 | expect.objectContaining(INVALID_TODO_ERROR)
72 | );
73 | expect(response.statusCode).toBe(StatusCodes.BAD_REQUEST);
at src/server.test.ts:70:29
at fulfilled (src/server.test.ts:5:58)
β todo βΊ PUT /todo/:id βΊ updates the todo with the given id
expect(received).toBe(expected) // Object.is equality
Expected: 202
Received: 500
87 |
88 | const response = await request(app).put('/todo/1').send(todo);
> 89 | expect(response.statusCode).toBe(StatusCodes.ACCEPTED);
| ^
90 | expect(response.body).toEqual(
91 | expect.objectContaining({
92 | // partial match of title string
at src/server.test.ts:89:35
at fulfilled (src/server.test.ts:5:58)
β todo βΊ PUT /todo/:id βΊ responds with the error when malformed Todo
expect(received).toEqual(expected) // deep equality
- Expected - 3
+ Received + 1
- ObjectContaining {
- "error": "Invalid todo",
- }
+ Object {}
100 | const response = await request(app).put('/todo/2').send(todo);
101 |
> 102 | expect(response.body).toEqual(
| ^
103 | expect.objectContaining(INVALID_TODO_ERROR)
104 | );
105 | expect(response.statusCode).toBe(StatusCodes.BAD_REQUEST);
at src/server.test.ts:102:29
at fulfilled (src/server.test.ts:5:58)
β todo βΊ PUT /todo/:id βΊ responds with the error when id not found
expect(received).toEqual(expected) // deep equality
- Expected - 3
+ Received + 1
- ObjectContaining {
- "error": StringMatching /Todo not found/,
- }
+ Object {}
110 | const response = await request(app).put('/todo/100').send(todo);
111 |
> 112 | expect(response.body).toEqual(
| ^
113 | expect.objectContaining(TODO_NOT_FOUND_ERROR)
114 | );
115 | expect(response.statusCode).toBe(StatusCodes.NOT_FOUND);
at src/server.test.ts:112:29
at fulfilled (src/server.test.ts:5:58)
β todo βΊ PUT /todo/:id βΊ responds with the error when Todo has extra properties
expect(received).toEqual(expected) // deep equality
- Expected - 3
+ Received + 1
- ObjectContaining {
- "error": "Invalid todo",
- }
+ Object {}
120 | const response = await request(app).put('/todo/2').send(todo);
121 |
> 122 | expect(response.body).toEqual(
| ^
123 | expect.objectContaining(INVALID_TODO_ERROR)
124 | );
125 | expect(response.statusCode).toBe(StatusCodes.BAD_REQUEST);
at src/server.test.ts:122:29
at fulfilled (src/server.test.ts:5:58)
β todo βΊ PUT /todo/:id βΊ responds with the error when title has over 1000k
expect(received).toEqual(expected) // deep equality
- Expected - 3
+ Received + 1
- ObjectContaining {
- "error": "Invalid todo",
- }
+ Object {}
129 | const response = await request(app).put('/todo/2').send(todo);
130 |
> 131 | expect(response.body).toEqual(
| ^
132 | expect.objectContaining(INVALID_TODO_ERROR)
133 | );
134 | expect(response.statusCode).toBe(StatusCodes.BAD_REQUEST);
at src/server.test.ts:131:29
at fulfilled (src/server.test.ts:5:58)
β todo βΊ DELETE /todo/:id βΊ deletes the todo with the given id
expect(received).toEqual(expected) // deep equality
- Expected - 3
+ Received + 1
- ObjectContaining {
- "id": 1,
- }
+ Object {}
142 | it('deletes the todo with the given id', async () => {
143 | const response = await request(app).delete('/todo/1');
> 144 | expect(response.body).toEqual(expect.objectContaining({ id: 1 }));
| ^
145 | expect(response.statusCode).toBe(StatusCodes.ACCEPTED);
146 | });
147 | it('responds with the error when malformed id', async () => {
at src/server.test.ts:144:29
at fulfilled (src/server.test.ts:5:58)
β todo βΊ DELETE /todo/:id βΊ responds with the error when malformed id
expect(received).toEqual(expected) // deep equality
- Expected - 3
+ Received + 1
- ObjectContaining {
- "error": "Invalid id",
- }
+ Object {}
148 | const response = await request(app).delete('/todo/dog');
149 |
> 150 | expect(response.body).toEqual(expect.objectContaining(INVALID_ID_ERROR));
| ^
151 | expect(response.statusCode).toBe(StatusCodes.BAD_REQUEST);
152 | });
153 | it('responds with the error when id not found', async () => {
at src/server.test.ts:150:29
at fulfilled (src/server.test.ts:5:58)
β todo βΊ DELETE /todo/:id βΊ responds with the error when id not found
expect(received).toEqual(expected) // deep equality
- Expected - 3
+ Received + 1
- ObjectContaining {
- "error": StringMatching /Todo not found/,
- }
+ Object {}
154 | const response = await request(app).delete('/todo/100');
155 |
> 156 | expect(response.body).toEqual(
| ^
157 | expect.objectContaining(TODO_NOT_FOUND_ERROR)
158 | );
159 | expect(response.statusCode).toBe(StatusCodes.NOT_FOUND);
at src/server.test.ts:156:29
at fulfilled (src/server.test.ts:5:58)
-|---------|----------|---------|---------|-------------------
| % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-|---------|----------|---------|---------|-------------------
| 44.85 | 0 | 9.09 | 42.51 |
| 52.83 | 0 | 14.28 | 51.92 |
| 20 | 0 | 0 | 15.78 | 6-47
| 72.72 | 0 | 25 | 72.72 | 26,35,40-42,48-53
| 46.34 | 0 | 12.5 | 39.39 |
| 46.34 | 0 | 12.5 | 39.39 | ...68,72-77,82-89
| 50 | 100 | 0 | 50 |
| 50 | 100 | 0 | 50 | 6-7
| 31.57 | 0 | 0 | 31.57 |
| 31.57 | 0 | 0 | 31.57 | 18-69
-|---------|----------|---------|---------|-------------------
Test Suites: 1 failed, 1 total
Tests: 13 failed, 13 total
Snapshots: 0 total
Time: 3.153 s
Ran all test suites.
npm ERR! Lifecycle script `test` failed with error:
npm ERR! Error: command failed
npm ERR! in workspace: [email protected]
npm ERR! at location: /workspaces/cloud-native-todo/api-todo