partey_workadventure/tests/tests/utils/log.ts
David Négrier eac4bb2875 Refactoring test cafe tests
- Using "Roles" to log users
- Adding seemingly useless import statement but important for code completion
2021-11-28 16:43:12 +01:00

21 lines
546 B
TypeScript

import { Selector } from 'testcafe';
/**
* Tries to find a given log message in the logs (for 10 seconds)
*/
export async function assertLogMessage(t: TestController, message: string): Promise<void> {
let i = 0;
let logs: string[]|undefined;
do {
const messages = await t.getBrowserConsoleMessages();
logs = messages['log'];
if (logs.find((str) => str === message)) {
break;
}
await t.wait(1000);
i++;
} while (i < 10);
await t.expect(logs).contains(message);
}