0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-02-24 22:05:56 -05:00

refactor(core): clear mocks after each test (#559)

This commit is contained in:
IceHe.xyz 2022-04-18 12:50:49 +08:00 committed by GitHub
parent df46593844
commit 1ef04bd45d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

View file

@ -16,11 +16,14 @@ describe('koaErrorHandler middleware', () => {
const next = jest.fn().mockReturnValue(Promise.resolve());
beforeEach(() => {
jest.clearAllMocks();
ctx.body = mockBody;
ctx.status = 200;
});
afterEach(() => {
jest.clearAllMocks();
});
it('expect to return error response if error type is RequestError', async () => {
const error = new RequestError('auth.unauthorized');
next.mockRejectedValueOnce(error);

View file

@ -19,6 +19,9 @@ describe('koaSpaProxy middleware', () => {
beforeEach(() => {
process.env = { ...envBackup };
});
afterEach(() => {
jest.clearAllMocks();
jest.resetModules();
});

View file

@ -26,7 +26,7 @@ describe('koaUserLog middleware', () => {
payload: { applicationId: 'foo' },
};
beforeEach(() => {
afterEach(() => {
jest.clearAllMocks();
});