diff --git a/.mocharc.js b/.mocharc.js index 890fca78e6b9..ff6200513b96 100644 --- a/.mocharc.js +++ b/.mocharc.js @@ -1,23 +1,6 @@ module.exports = { // TODO: Remove the `exit` setting, it can hide broken tests. exit: true, - ignore: [ - './app/scripts/lib/**/*.test.js', - './app/scripts/migrations/*.test.js', - './app/scripts/platforms/*.test.js', - './app/scripts/controllers/app-state.test.js', - './app/scripts/controllers/permissions/**/*.test.js', - './app/scripts/controllers/mmi-controller.test.ts', - './app/scripts/metamask-controller.actions.test.js', - './app/scripts/detect-multiple-instances.test.js', - './app/scripts/controllers/swaps.test.js', - './app/scripts/controllers/metametrics.test.js', - './app/scripts/controllers/preferences.test.js', - './app/scripts/constants/error-utils.test.js', - './app/scripts/metamask-controller.test.js', - './development/fitness-functions/**/*.test.ts', - './test/e2e/helpers.test.js', - ], recursive: true, require: ['test/env.js', 'test/setup.js'], }; diff --git a/jest.config.js b/jest.config.js index 1d6f86938950..0d8446a1fd95 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,26 +1,10 @@ +const { legacyMochaTests } = require('./test/mocha/legacy-mocha-tests'); + module.exports = { collectCoverageFrom: [ - '/app/scripts/constants/error-utils.js', - '/app/scripts/controllers/app-metadata.ts', - '/app/scripts/controllers/permissions/**/*.js', - '/app/scripts/controllers/sign.ts', - '/app/scripts/controllers/decrypt-message.ts', - '/app/scripts/controllers/encryption-public-key.ts', - '/app/scripts/controllers/transactions/etherscan.ts', - '/app/scripts/controllers/transactions/EtherscanRemoteTransactionSource.ts', - '/app/scripts/controllers/transactions/IncomingTransactionHelper.ts', - '/app/scripts/controllers/preferences.js', - '/app/scripts/flask/**/*.js', - '/app/scripts/lib/**/*.(js|ts)', - '/app/scripts/metamask-controller.js', - '/app/scripts/migrations/*.js', - '/app/scripts/migrations/*.ts', - '!/app/scripts/migrations/*.test.(js|ts)', - '/app/scripts/platforms/*.js', + '/app/scripts/**/*.(js|ts|tsx)', '/shared/**/*.(js|ts|tsx)', '/ui/**/*.(js|ts|tsx)', - '/development/fitness-functions/**/*.test.(js|ts|tsx)', - '/test/e2e/helpers.test.js', ], coverageDirectory: './coverage', coveragePathIgnorePatterns: ['.stories.*', '.snap'], @@ -41,39 +25,15 @@ module.exports = { setupFiles: ['/test/setup.js', '/test/env.js'], setupFilesAfterEnv: ['/test/jest/setup.js'], testMatch: [ - '/app/scripts/constants/error-utils.test.js', - '/app/scripts/controllers/app-metadata.test.ts', - '/app/scripts/controllers/app-state.test.js', - '/app/scripts/controllers/encryption-public-key.test.ts', - '/app/scripts/controllers/transactions/etherscan.test.ts', - '/app/scripts/controllers/transactions/EtherscanRemoteTransactionSource.test.ts', - '/app/scripts/controllers/transactions/IncomingTransactionHelper.test.ts', - '/app/scripts/controllers/onboarding.test.ts', - '/app/scripts/controllers/mmi-controller.test.ts', - '/app/scripts/controllers/permissions/**/*.test.js', - '/app/scripts/controllers/preferences.test.js', - '/app/scripts/controllers/sign.test.ts', - '/app/scripts/controllers/decrypt-message.test.ts', - '/app/scripts/controllers/authentication/**/*.test.ts', - '/app/scripts/controllers/push-platform-notifications/**/*.test.ts', - '/app/scripts/controllers/user-storage/**/*.test.ts', - '/app/scripts/controllers/metamask-notifications/**/*.test.ts', - '/app/scripts/metamask-controller.actions.test.js', - '/app/scripts/detect-multiple-instances.test.js', - '/app/scripts/controllers/swaps.test.js', - '/app/scripts/controllers/metametrics.test.js', - '/app/scripts/flask/**/*.test.js', - '/app/scripts/lib/**/*.test.(js|ts)', - '/app/scripts/lib/createRPCMethodTrackingMiddleware.test.js', - '/app/scripts/metamask-controller.test.js', - '/app/scripts/migrations/*.test.(js|ts)', - '/app/scripts/platforms/*.test.js', - '/app/scripts/translate.test.ts', - '/shared/**/*.test.(js|ts)', + '/app/scripts/**/*.test.(js|ts|tsx)', + '/shared/**/*.test.(js|ts|tsx)', '/ui/**/*.test.(js|ts|tsx)', '/development/fitness-functions/**/*.test.(js|ts|tsx)', '/test/e2e/helpers.test.js', ], + testPathIgnorePatterns: legacyMochaTests.map((filePath) => { + return `/${filePath}`; + }), testTimeout: 5500, // We have to specify the environment we are running in, which is jsdom. The // default is 'node'. This can be modified *per file* using a comment at the diff --git a/test/mocha/legacy-mocha-tests.js b/test/mocha/legacy-mocha-tests.js new file mode 100644 index 000000000000..3b145e92fc8b --- /dev/null +++ b/test/mocha/legacy-mocha-tests.js @@ -0,0 +1,10 @@ +// This is a list of remaining unit tests written for Mocha. +// We are in the middle of a migration from Mocha to Jest. Please do not add any additional test +// files to this list. We should only be removing files. +const legacyMochaTests = [ + 'app/scripts/metamask-controller.actions.test.js', +] + +module.exports = { + legacyMochaTests, +} diff --git a/test/run-unit-tests.js b/test/run-unit-tests.js index a58a858c09c8..e1072ae77d74 100644 --- a/test/run-unit-tests.js +++ b/test/run-unit-tests.js @@ -1,6 +1,7 @@ const { hideBin } = require('yargs/helpers'); const yargs = require('yargs/yargs'); const { runCommand, runInShell } = require('../development/lib/run-command'); +const { legacyMochaTests } = require('./mocha/legacy-mocha-tests'); const { CIRCLE_NODE_INDEX, CIRCLE_NODE_TOTAL } = process.env; @@ -71,7 +72,7 @@ async function runJest( * @param {boolean} coverage - Use nyc to collect coverage */ async function runMocha({ coverage }) { - const options = ['mocha', './app/**/*.test.js']; + const options = ['mocha', ...legacyMochaTests]; // If coverage is true, then we need to run nyc as the first command // and mocha after, so we use unshift to add three options to the beginning // of the options array.