Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions jest.config.packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ module.exports = {

// "resetMocks" resets all mocks, including mocked modules, to jest.fn(),
// between each test case.
// TODO: Enable
// resetMocks: true,
resetMocks: true,

// Reset the module registry before running each individual test
// resetModules: false,
Expand Down
4 changes: 4 additions & 0 deletions jest.config.scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ module.exports = {
// // A preset that is used as a base for Jest's configuration
// preset: 'ts-jest',

// "resetMocks" resets all mocks, including mocked modules, to jest.fn(),
// between each test case.
resetMocks: true,

// "restoreMocks" restores all mocks created using jest.spyOn to their
// original implementations, between each test. It does not affect mocked
// modules.
Expand Down
11 changes: 0 additions & 11 deletions packages/accounts-controller/src/AccountsController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,6 @@ function setupAccountsController({
}

describe('AccountsController', () => {
afterEach(() => {
jest.resetAllMocks();
});

describe('onSnapStateChange', () => {
it('be used enable an account if the Snap is enabled and not blocked', async () => {
const messenger = buildMessenger();
Expand Down Expand Up @@ -449,9 +445,6 @@ describe('AccountsController', () => {
});

describe('onKeyringStateChange', () => {
afterEach(() => {
jest.clearAllMocks();
});
it('not update state when only keyring is unlocked without any keyrings', async () => {
const messenger = buildMessenger();
const { accountsController } = setupAccountsController({
Expand Down Expand Up @@ -1304,10 +1297,6 @@ describe('AccountsController', () => {
);
});

afterEach(() => {
jest.clearAllMocks();
});

it('update accounts with normal accounts', async () => {
mockUUID.mockReturnValueOnce('mock-id').mockReturnValueOnce('mock-id2');
const messenger = buildMessenger();
Expand Down
8 changes: 5 additions & 3 deletions packages/approval-controller/src/ApprovalController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { ControllerMessenger } from '@metamask/base-controller';
import { errorCodes, JsonRpcError } from '@metamask/rpc-errors';
import { nanoid } from 'nanoid';

import type {
AddApprovalOptions,
Expand All @@ -24,9 +25,9 @@ import {
NoApprovalFlowsError,
} from './errors';

jest.mock('nanoid', () => ({
nanoid: jest.fn(() => 'TestId'),
}));
jest.mock('nanoid');

const nanoidMock = jest.mocked(nanoid);

const PENDING_APPROVALS_STORE_KEY = 'pendingApprovals';
const APPROVAL_FLOWS_STORE_KEY = 'approvalFlows';
Expand Down Expand Up @@ -243,6 +244,7 @@ describe('approval controller', () => {
let showApprovalRequest: jest.Mock;

beforeEach(() => {
nanoidMock.mockReturnValue('TestId');
jest.spyOn(global.console, 'info').mockImplementation(() => undefined);

showApprovalRequest = jest.fn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ describe('CurrencyRateController', () => {

afterEach(() => {
clock.restore();
jest.restoreAllMocks();
});

it('should set default state', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ function setupRatesController({
describe('RatesController', () => {
let clock: sinon.SinonFakeTimers;

afterEach(() => {
jest.resetAllMocks();
});

describe('construct', () => {
it('constructs the RatesController with default values', () => {
const ratesController = setupRatesController({
Expand All @@ -116,7 +112,6 @@ describe('RatesController', () => {

afterEach(() => {
clock.restore();
jest.restoreAllMocks();
});

it('starts the polling process with default values', async () => {
Expand Down Expand Up @@ -249,7 +244,6 @@ describe('RatesController', () => {

afterEach(() => {
clock.restore();
jest.restoreAllMocks();
});

it('stops the polling process', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,6 @@ const getRestrictedMessenger = (

describe('TokenListController', () => {
afterEach(() => {
jest.restoreAllMocks();
jest.clearAllTimers();
sinon.restore();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ function buildTokenRatesControllerMessenger(
}

describe('TokenRatesController', () => {
afterEach(() => {
jest.restoreAllMocks();
});

describe('constructor', () => {
let clock: sinon.SinonFakeTimers;

Expand Down
1 change: 0 additions & 1 deletion packages/assets-controllers/src/TokensController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ describe('TokensController', () => {

afterEach(() => {
sinon.restore();
jest.resetAllMocks();
});

it('should set default state', async () => {
Expand Down
Loading