Использовать grep -P - который позволяет поддерживать регулярные выражения в стиле Perl.
grep -P "abc.*def" myfile
Как было предложено Марком Мейером в комментариях, сделать startTimerWithAsyncCallback
возвращение Обещания более удобным для тестирования
function startTimerWithAsyncCallback(
firstAsyncFunction,
secondAsyncFunction,
thirdAsyncFunction,
millis,
) {
return new Promise((resolve) => { // <==
setTimeout(async () => {
await firstAsyncFunction();
await secondAsyncFunction();
await thirdAsyncFunction();
resolve(); // <==
}, millis);
});
}
describe('Using async callbacks with timers', () => {
test('fake timers', async () => {
jest.useFakeTimers();
const firstAsyncFunction = jest.fn();
const secondAsyncFunction = jest.fn();
const thirdAsyncFunction = jest.fn();
const promise = startTimerWithAsyncCallback( // <==
firstAsyncFunction,
secondAsyncFunction,
thirdAsyncFunction,
1000,
);
jest.advanceTimersByTime(2000);
await promise; <==
expect(firstAsyncFunction).toHaveBeenCalled();
expect(secondAsyncFunction).toHaveBeenCalled();
expect(thirdAsyncFunction).toHaveBeenCalled();
});
});