From 3f729ef6e61ff3b795ec2f5f072029451c3d694a Mon Sep 17 00:00:00 2001 From: liximomo Date: Tue, 26 Jul 2022 08:49:43 +0800 Subject: [PATCH] fix: unstable test --- test/e2e/custom-app.test.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/e2e/custom-app.test.ts b/test/e2e/custom-app.test.ts index f669ce7c0..23f8cc11c 100644 --- a/test/e2e/custom-app.test.ts +++ b/test/e2e/custom-app.test.ts @@ -36,9 +36,14 @@ describe('custom/app.js', () => { it('should get correct log', async () => { const logSpy = jest.spyOn(console, 'log'); + let logs = ''; + logSpy.mockImplementation((...args) => { + logs += args.filter(a => typeof a === 'string').join(''); + }); + page = await ctx.browser.page(ctx.url('/')); + expect(logs).toMatch('init\ndispose\n'); - expect(logSpy).toHaveBeenNthCalledWith(1, 'init\n'); - expect(logSpy).toHaveBeenNthCalledWith(2, 'dispose\n'); + logSpy.mockRestore(); }); });