Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Initialize all test data in setup.js #437

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions test/config/setup.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import { spawn } from "child_process";
import request from "supertest";
import app from "#app"; // Update this import based on your app"s structure
import connector from "#models/databaseUtil"; // Update this import

const server = app.listen(null, () => {
connector.set("debug", false);
connector.set("debug", false);
});
const agent = request.agent(server);

const child = spawn("node", ["./misc/initDB"]);
global.server = server;
global.agent = agent;
global.child = child;
export default async () => {
global.server = server;
global.agent = agent;
};
global.server = server;
global.agent = agent;
global.child = child;
};
11 changes: 9 additions & 2 deletions test/config/teardown.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
const teardownProcess = () => {
global.child.kill();
};

global.server.close();
global.agent.app.close();
export default async () => {
};
global.child.stdin.end();
global.child.stdout.destroy();
global.child.stderr.destroy();
setTimeout(teardownProcess, 500);
export default async () => {};