Fix the test script yarn test:manual and add it to tsconfig (#234)

* Add test:manual launch script to tsconfig

this is so we won't keep breaking it
This commit is contained in:
Gnuxie 2022-02-24 14:46:15 +00:00 committed by GitHub
parent 7353ba4919
commit 17dd0aa173
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 9 deletions

View File

@ -9,6 +9,7 @@
"private": true,
"scripts": {
"build": "tsc",
"postbuild": "rm -rf lib/test/ && cp -r lib/src/* lib/ && rm -rf lib/src/",
"lint": "tslint --project ./tsconfig.json -t stylish",
"start:dev": "yarn build && node --async-stack-traces lib/index.js",
"test": "ts-mocha --project ./tsconfig.json test/commands/**/*.ts",

View File

@ -19,7 +19,7 @@ const REGISTRATION_RETRY_BASE_DELAY_MS = 100;
export async function registerUser(username: string, displayname: string, password: string, admin: boolean): Promise<void> {
let registerUrl = `${config.homeserverUrl}/_synapse/admin/v1/register`
const data: {nonce: string} = await new Promise((resolve, reject) => {
getRequestFn()({uri: registerUrl, method: "GET", timeout: 60000}, (error, response, resBody) => {
getRequestFn()({uri: registerUrl, method: "GET", timeout: 60000}, (error: any, response: any, resBody: any) => {
error ? reject(error) : resolve(JSON.parse(resBody))
});
});
@ -42,7 +42,7 @@ export async function registerUser(username: string, displayname: string, passwo
timeout: 60000
}
return await new Promise((resolve, reject) => {
getRequestFn()(params, error => error ? reject(error) : resolve());
getRequestFn()(params, (error: any) => error ? reject(error) : resolve());
});
} catch (ex) {
// In case of timeout or throttling, backoff and retry.
@ -174,8 +174,8 @@ export async function resetRatelimitForUser(userId: string) {
* @param cb The callback when a m.notice event is found in targetRoomId.
* @returns The callback to pass to `MatrixClient.on('room.message', cb)`
*/
export function noticeListener(targetRoomdId: string, cb) {
return (roomId, event) => {
export function noticeListener(targetRoomdId: string, cb: (event: any) => void) {
return (roomId: string, event: any) => {
if (roomId !== targetRoomdId) return;
if (event?.content?.msgtype !== "m.notice") return;
cb(event);

View File

@ -82,10 +82,10 @@ export async function makeMjolnir(): Promise<Mjolnir> {
await overrideRatelimitForUser(await client.getUserId());
patchMatrixClient();
await ensureAliasedRoomExists(client, config.managementRoom);
let mjolnir = await Mjolnir.setupMjolnirFromConfig(client);
let mj = await Mjolnir.setupMjolnirFromConfig(client);
globalClient = client;
globalMjolnir = mjolnir;
return mjolnir;
globalMjolnir = mj;
return mj;
}
/**

View File

@ -19,6 +19,7 @@
]
},
"include": [
"./src/**/*"
"./src/**/*",
"./test/integration/manualLaunchScript.ts"
]
}