Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cyri113 committed May 21, 2023
1 parent 42a60c4 commit a80439c
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 79 deletions.
7 changes: 7 additions & 0 deletions __test__/app.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import request from "supertest";
import app from "../src/app";
import { emailQueue, imageProcessingQueue } from "../src/queues";

describe("GET /", () => {

afterAll(async () => {
await emailQueue.close()
await imageProcessingQueue.close()
})

it("should respond with 'Express + TypeScript Server'", async () => {
const response = await request(app).get("/");
expect(response.status).toBe(200);
Expand Down
49 changes: 0 additions & 49 deletions __test__/index.test.ts

This file was deleted.

6 changes: 6 additions & 0 deletions __test__/queues/queueByName.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import imageProcessingQueue from "../../src/queues/imageProcessing.queue";
import queueByName from "../../src/queues/queueByName";

describe("queueByName", () => {

afterAll(async () => {
await emailQueue.close()
await imageProcessingQueue.close()
})

it("should return emailQueue for name 'email'", () => {
expect(queueByName("email")).toBe(emailQueue);
});
Expand Down
7 changes: 7 additions & 0 deletions __test__/routes/posts.route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import app from "../../src/app";
import mongoose from "mongoose";
import Post from "../../src/models/post.model";
import { env } from "../../src/config";
import { emailQueue, imageProcessingQueue } from "../../src/queues";

beforeEach(async () => {
mongoose.set("strictQuery", true);
Expand All @@ -15,6 +16,12 @@ afterEach(async () => {
});

describe("/posts routes", () => {

afterAll(async () => {
await emailQueue.close()
await imageProcessingQueue.close()
})

test("GET /posts", async () => {
const post = await Post.create({
title: "Post 1",
Expand Down
28 changes: 0 additions & 28 deletions __test__/workers/email.worker.test.ts

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"build": "npx tsc",
"start": "node dist/index.js",
"dev": "env-cmd nodemon ./src/index.ts",
"test": "env-cmd jest --coverage",
"test": "env-cmd jest --coverage --detectOpenHandles",
"prettier": "npx prettier --write .",
"lint": "npx eslint ."
},
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"./src/**/*",
"./__test__/**/*",
".eslintrc.json",
"jest.config.ts"
"jest.config.ts",
]
}

0 comments on commit a80439c

Please sign in to comment.