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:
parent
df46593844
commit
1ef04bd45d
3 changed files with 8 additions and 2 deletions
|
@ -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);
|
||||
|
|
|
@ -19,6 +19,9 @@ describe('koaSpaProxy middleware', () => {
|
|||
|
||||
beforeEach(() => {
|
||||
process.env = { ...envBackup };
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
jest.resetModules();
|
||||
});
|
||||
|
|
|
@ -26,7 +26,7 @@ describe('koaUserLog middleware', () => {
|
|||
payload: { applicationId: 'foo' },
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue