Jest and Vitest are used to ensure that code is working as expected. Ideally, all packages should have 100% test coverage.
Please follow the MetaMask unit testing guidelines when writing tests.
If you need to customize the behavior of the test runner for a package, see jest.config.cjs or vitest.config.js within that package.
- Run
yarn workspace <workspaceName> run testto run all tests for a package. - Run
yarn workspace <workspaceName> run jest --no-coverage <file>(Jest) oryarn workspace <workspaceName> run vitest run <file>(Vitest) to run a single test file. - Run
yarn testto run tests for all packages.
Note
workspaceNamein these commands is thenamefield within a package'spackage.json, e.g.,@metamask/address-book-controller, not the directory where it is located, e.g.,packages/address-book-controller.