UNPKG

nx-mesh

Version:
36 lines 2.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.addJest = void 0; const tslib_1 = require("tslib"); const devkit_1 = require("@nrwl/devkit"); const jest_1 = require("@nrwl/jest"); function addJest(host, options) { return tslib_1.__awaiter(this, void 0, void 0, function* () { if (options.unitTestRunner !== 'jest') { // eslint-disable-next-line @typescript-eslint/no-empty-function return () => { }; } const jestTask = yield (0, jest_1.jestProjectGenerator)(host, Object.assign(Object.assign({}, options), { babelJest: options.babelJest, project: options.projectName, setupFile: 'none', skipFormat: options.skipFormat, skipSerializers: true, supportTsx: options.js, testEnvironment: 'node' })); const tsConfigSpecJson = (0, devkit_1.readJson)(host, (0, devkit_1.joinPathFragments)(options.projectDirectory, 'tsconfig.spec.json')); (0, devkit_1.updateJson)(host, (0, devkit_1.joinPathFragments)(options.projectDirectory, 'tsconfig.json'), (json) => { var _a, _b, _c, _d; var _e; (_a = json.compilerOptions) !== null && _a !== void 0 ? _a : (json.compilerOptions = {}); (_b = (_e = json.compilerOptions).types) !== null && _b !== void 0 ? _b : (_e.types = []); json.compilerOptions.types.push(...((_d = (_c = tsConfigSpecJson === null || tsConfigSpecJson === void 0 ? void 0 : tsConfigSpecJson.compilerOptions) === null || _c === void 0 ? void 0 : _c.types) !== null && _d !== void 0 ? _d : [])); return json; }); (0, devkit_1.updateJson)(host, (0, devkit_1.joinPathFragments)(options.projectDirectory, 'tsconfig.spec.json'), (json) => { // have to override exclude otherwise lint will fail with setParserOptionsProject and jest.config.ts if (options.setParserOptionsProject) { const tsConfig = (0, devkit_1.readJson)(host, (0, devkit_1.joinPathFragments)(options.projectDirectory, 'tsconfig.json')); json.exclude = tsConfig.exclude.filter((excluded) => excluded !== 'jest.config.ts'); } return json; }); return jestTask; }); } exports.addJest = addJest; exports.default = addJest; //# sourceMappingURL=add-jest.js.map