Skip to content

Commit a4e71b5

Browse files
authored
Merge pull request #7 from debs-obrien:fix-awaits
Fix API test response validation
2 parents 69ef7e3 + 191d63d commit a4e71b5

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

tests/logged-out/api.spec.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ test.describe('movie categories', () => {
88
const response = await request.get(`/3/movie/popular`, {
99
params: { page: 1 },
1010
});
11-
expect(response).toBeOK();
11+
await expect(response).toBeOK();
1212
const jsonResponse = await response.json();
1313
const movies = jsonResponse.results;
1414
// Loops over the popularity and checks they are in the correct order
@@ -23,7 +23,7 @@ test.describe('movie categories', () => {
2323
const response = await request.get(`/3/movie/top_rated`, {
2424
params: { page: 1 },
2525
});
26-
expect(response).toBeOK();
26+
await expect(response).toBeOK();
2727
const jsonResponse = await response.json();
2828
const movies = jsonResponse.results;
2929
// Loops over the vote averages and checks they are in the correct order
@@ -38,7 +38,7 @@ test.describe('movie categories', () => {
3838
const response = await request.get(`/3/movie/upcoming`, {
3939
params: { page: 1 },
4040
});
41-
expect(response).toBeOK();
41+
await expect(response).toBeOK();
4242
const jsonResponse = await response.json();
4343
const movies = jsonResponse.results;
4444
// Loops over the release dates and checks they are in the correct order
@@ -54,7 +54,7 @@ test('action genre movies', async ({ request }) => {
5454
const response = await request.get(`/3/discover/movie`, {
5555
params: { with_genres: 28, page: 1 },
5656
}); // genre id for action is 28
57-
expect(response).toBeOK();
57+
await expect(response).toBeOK();
5858
const jsonResponse = await response.json();
5959
// Filters out action movies from the JSON response
6060
const nonActionMovies = jsonResponse.results.filter(
@@ -67,7 +67,7 @@ test('movie search', async ({ request }) => {
6767
const response = await request.get(`/3/search/movie`, {
6868
params: { query: 'Twisters' },
6969
});
70-
expect(response).toBeOK();
70+
await expect(response).toBeOK();
7171
expect(await response.json()).toEqual({
7272
total_pages: 1,
7373
total_results: 1,
@@ -91,7 +91,7 @@ test('movie search', async ({ request }) => {
9191

9292
test('movie credits', async ({ request }) => {
9393
const response = await request.get(`/3/movie/tt12584954/credits`);
94-
expect(response).toBeOK();
94+
await expect(response).toBeOK();
9595
expect(await response.json()).toEqual(
9696
expect.objectContaining({
9797
cast: expect.arrayContaining([
@@ -124,7 +124,7 @@ test.describe('movie sorting', () => {
124124
const response = await request.get(`/3/discover/movie`, {
125125
params: { with_genres: 28, page: 1, sort_by: 'popularity.desc' },
126126
});
127-
expect(response).toBeOK();
127+
await expect(response).toBeOK();
128128
const jsonResponse = await response.json();
129129
const movies = jsonResponse.results;
130130
// Loops over the popularity and checks they are in the correct order
@@ -139,7 +139,7 @@ test.describe('movie sorting', () => {
139139
const response = await request.get(`/3/discover/movie`, {
140140
params: { with_genres: 28, page: 1, sort_by: 'vote_average.desc' },
141141
});
142-
expect(response).toBeOK();
142+
await expect(response).toBeOK();
143143
const jsonResponse = await response.json();
144144
const movies = jsonResponse.results;
145145
// Loops over the vote averages and checks they are in the correct order
@@ -154,7 +154,7 @@ test.describe('movie sorting', () => {
154154
const response = await request.get(`/3/discover/movie`, {
155155
params: { with_genres: 28, page: 1, sort_by: 'original_title.asc' },
156156
});
157-
expect(response).toBeOK();
157+
await expect(response).toBeOK();
158158
const jsonResponse = await response.json();
159159
const movies = jsonResponse.results;
160160
// Loops over the titles and checks they are in the correct order
@@ -169,7 +169,7 @@ test.describe('movie sorting', () => {
169169
const response = await request.get(`/3/discover/movie`, {
170170
params: { with_genres: 28, page: 1, sort_by: 'release_date.desc' },
171171
});
172-
expect(response).toBeOK();
172+
await expect(response).toBeOK();
173173
const jsonResponse = await response.json();
174174
const movies = jsonResponse.results;
175175
// Loops over the release dates and checks they are in the correct order
@@ -183,7 +183,7 @@ test.describe('movie sorting', () => {
183183

184184
test('configuration', async ({ request }) => {
185185
const response = await request.get(`/3/configuration`);
186-
expect(response).toBeOK();
186+
await expect(response).toBeOK();
187187
expect(await response.json()).toEqual({
188188
change_keys: expect.any(Array),
189189
images: expect.objectContaining({

0 commit comments

Comments
 (0)