Skip to content

Commit 8972700

Browse files
Adding sanity tests
1 parent ee34596 commit 8972700

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"test:single_character": "jest --group=single_character",
55
"test:all_characters": "jest --group=all_characters",
66
"test:multiple_characters": "jest --group=multiple_characters",
7-
"test:filter_characters": "jest --group=filter_characters"
7+
"test:filter_characters": "jest --group=filter_characters",
8+
"test:sanity": "jest --group=sanity_tests"
89
},
910
"devDependencies": {
1011
"@types/jest": "^29.5.12",
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { assertStatusCode } from "../../../helpers/assertionsHelper";
2+
import { makeRequest } from "../../../helpers/makeRequest";
3+
4+
const BASE_URL = "https://rickandmortyapi.com/api/";
5+
6+
/**
7+
* Sanity Tests
8+
* @group sanity_tests
9+
*/
10+
describe("Rick and Morty API - Sanity Tests", () => {
11+
test("should respond with a 200 status for the characters endpoint", async () => {
12+
const response = await makeRequest("get", `${BASE_URL}/character`);
13+
assertStatusCode(response, 200);
14+
});
15+
16+
test("should respond with a 200 status for the episodes endpoint", async () => {
17+
const response = await makeRequest("get", `${BASE_URL}/episode`);
18+
assertStatusCode(response, 200);
19+
});
20+
21+
test("should respond with a 200 status for the locations endpoint", async () => {
22+
const response = await makeRequest("get", `${BASE_URL}/location`);
23+
assertStatusCode(response, 200);
24+
});
25+
26+
test("should respond with a 200 status for the specific character endpoint", async () => {
27+
const response = await makeRequest("get", `${BASE_URL}/character/1`);
28+
assertStatusCode(response, 200);
29+
});
30+
31+
test("should return 404 for non-existent endpoint", async () => {
32+
const response = await makeRequest("get", `${BASE_URL}/nonexisting`);
33+
assertStatusCode(response, 404);
34+
});
35+
});

src/tests/api/sanity/healthcheck.tests.ts

Whitespace-only changes.

0 commit comments

Comments
 (0)