Skip to content

Commit

Permalink
Merge pull request #437 from tcet-opensource/feat-436-Initialize-all-…
Browse files Browse the repository at this point in the history
…test-data-in-setup.js

Feat: Initialize all test data in setup.js
  • Loading branch information
TejasNair9977 authored Oct 29, 2023
2 parents 186eb66 + 57e05c8 commit ff1d374
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
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 () => {};

0 comments on commit ff1d374

Please sign in to comment.