My current project involves creating a "Firm" microservice that handles firm registrations and user sign-ups within the firm. However, I'm encountering an issue while running tests on my route handlers where I get an error stating "Property 'id' does not exist on type 'Promise'". Can anyone point me in the right direction?
After marking the global.signin function as async and making changes like adding await buildFirm()
and replacing return [`session=${base64}`];
with ...
const cookie = [`session=${base64}`];
return new Promise<string[]>((resolve, reject) => {
resolve(cookie);
})
The previous error regarding 'id' disappears, but now I encounter a new error related to global.signin
saying "Type '() => Promise<string[]>' is not assignable to type '() => string[]'.
Type 'Promise<string[]>' is missing the following properties from type 'string[]': length, pop, push, concat, and more."
setup.ts (test setup):
import { MongoMemoryServer } from "mongodb-memory-server";
import mongoose from "mongoose";
import jwt from "jsonwebtoken";
import { Firm, FirmDoc } from '../models/firm';
declare global {
var rootsignin: () => string[];
}
declare global {
var signin: () => string[];
}
jest.mock("../nats-wrapper");
let mongo: any;
beforeAll(async () => {
jest.setTimeout(10000)
process.env.JWT_KEY = "asdfasdf";
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
const mongo = await MongoMemoryServer.create();
const mongoUri = mongo.getUri();
await mongoose.connect(mongoUri, {});
});
...
... (repeated code for brevity)
firm.ts (Firm Model):
import mongoose from 'mongoose';
import { FirmStatus } from "@mavata/common";
export { FirmStatus };
...
... (more code here)
If you have any insights or solutions to my problem, please let me. Thank you.