feat: init-express-backend #6
@ -1,12 +1,14 @@
|
||||
import request from "supertest";
|
||||
import app from "../src/app";
|
||||
import { Server, IncomingMessage, ServerResponse } from "http";
|
||||
import * as dotenv from "dotenv";
|
||||
|
||||
const port = 3000;
|
||||
dotenv.config({path: '../../.env'})
|
||||
const port = parseInt(process.env.BAR_PORT || '3000')
|
||||
|
||||
let serveur : Server<typeof IncomingMessage, typeof ServerResponse>
|
||||
|
||||
describe("Test the root path", () => {
|
||||
describe("Test the welcome path", () => {
|
||||
|
||||
beforeEach(() => {
|
||||
serveur = app.listen(port, () =>{
|
||||
@ -20,7 +22,7 @@ describe("Test the root path", () => {
|
||||
|
||||
test("It should response the GET method", done => {
|
||||
request(app)
|
||||
.get("/")
|
||||
.get("/welcome")
|
||||
.then(response => {
|
||||
expect(response.statusCode).toBe(200);
|
||||
done();
|
||||
@ -28,10 +30,11 @@ describe("Test the root path", () => {
|
||||
});
|
||||
|
||||
test("It should response the GET method", done => {
|
||||
const out = {hello:"world"};
|
||||
request(app)
|
||||
.get("/")
|
||||
.get("/welcome")
|
||||
.then(response => {
|
||||
expect(response.text).toEqual("hello world from dev")
|
||||
expect(response.text).toEqual(JSON.stringify(out))
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user