UNPKG

@nx/jest

Version:

The Nx Plugin for Jest contains executors and generators allowing your workspace to use the powerful Jest testing capabilities.

41 lines (40 loc) 1.82 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = default_1; const internal_1 = require("@nx/devkit/internal"); const devkit_1 = require("@nx/devkit"); // migration for https://github.com/jestjs/jest/commit/41133b526d2c17bc9758f90d6026b25301cf0552 async function default_1(tree) { // update options from project configs (0, internal_1.forEachExecutorOptions)(tree, '@nx/jest:jest', (_, project, target, configuration) => { const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, project); const config = configuration ? projectConfiguration.targets[target].configurations[configuration] : projectConfiguration.targets[target].options; renameTestPathPattern(config); (0, devkit_1.updateProjectConfiguration)(tree, project, projectConfiguration); }); // update options from nx.json target defaults. Migration order isn't // guaranteed, so a default may already be in the filtered array shape; // `updateTargetDefault` walks both the object and array value forms. const nxJson = (0, devkit_1.readNxJson)(tree); if (nxJson?.targetDefaults) { (0, internal_1.updateTargetDefault)(nxJson, { executor: '@nx/jest:jest' }, (config) => { if (config.options) { renameTestPathPattern(config.options); } Object.values(config.configurations ?? {}).forEach((c) => { renameTestPathPattern(c); }); }); (0, devkit_1.updateNxJson)(tree, nxJson); } await (0, devkit_1.formatFiles)(tree); } function renameTestPathPattern(config) { if (!config.testPathPattern) { return; } config.testPathPatterns = config.testPathPattern; delete config.testPathPattern; }