Running Jest Tests
This configuration allows you to run Jest tests for multiple projects within an Nx workspace. The 'projects' array specifies the paths to the projects you want to include.
module.exports = {
projects: ['<rootDir>/apps/my-app', '<rootDir>/libs/my-lib'],
};
Custom Jest Configuration
This sample shows how to create a custom Jest configuration for a specific project within an Nx workspace. It includes settings for transforming files, module file extensions, and coverage directory.
module.exports = {
displayName: 'my-app',
preset: '../../jest.preset.js',
transform: {
'^.+\\.[tj]sx?$': 'babel-jest',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/apps/my-app',
};
Running Tests with Nx CLI
You can run tests for a specific project using the Nx CLI. This command runs the tests for the 'my-app' project.
nx test my-app