mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-29 19:12:27 +08:00
fix(test/server): supertest-based tests no longer working
This commit is contained in:
parent
4dafa56671
commit
59663ed696
@ -1,8 +1,9 @@
|
|||||||
import { beforeAll, describe, expect, it } from "vitest";
|
import { beforeAll, describe, expect, it } from "vitest";
|
||||||
import supertest from "supertest";
|
import supertest from "supertest";
|
||||||
import { initializeTranslations } from "../services/i18n.js";
|
import { initializeTranslations } from "../services/i18n.js";
|
||||||
import type { Application, Request, Response, NextFunction } from "express";
|
import type { Application } from "express";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
|
import buildApp from "../app.js";
|
||||||
|
|
||||||
let app: Application;
|
let app: Application;
|
||||||
|
|
||||||
@ -10,7 +11,7 @@ describe("Login Route test", () => {
|
|||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
initializeTranslations();
|
initializeTranslations();
|
||||||
app = (await import("../app.js")).default;
|
app = await buildApp();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return the login page, when using a GET request", async () => {
|
it("should return the login page, when using a GET request", async () => {
|
||||||
|
@ -3,6 +3,7 @@ import supertest from "supertest";
|
|||||||
import { initializeTranslations } from "../services/i18n.js";
|
import { initializeTranslations } from "../services/i18n.js";
|
||||||
import type { Application, Request, Response, NextFunction } from "express";
|
import type { Application, Request, Response, NextFunction } from "express";
|
||||||
import { safeExtractMessageAndStackFromError } from "../services/utils.js";
|
import { safeExtractMessageAndStackFromError } from "../services/utils.js";
|
||||||
|
import buildApp from "../app.js";
|
||||||
|
|
||||||
let app: Application;
|
let app: Application;
|
||||||
|
|
||||||
@ -11,7 +12,7 @@ describe("Share API test", () => {
|
|||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
initializeTranslations();
|
initializeTranslations();
|
||||||
app = (await import("../app.js")).default;
|
app = await buildApp();
|
||||||
app.use((err: unknown, req: Request, res: Response, next: NextFunction) => {
|
app.use((err: unknown, req: Request, res: Response, next: NextFunction) => {
|
||||||
const [ errMessage ] = safeExtractMessageAndStackFromError(err);
|
const [ errMessage ] = safeExtractMessageAndStackFromError(err);
|
||||||
if (errMessage.includes("Cannot set headers after they are sent to the client")) {
|
if (errMessage.includes("Cannot set headers after they are sent to the client")) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user