UNPKG

@yolkai/nx-workspace

Version:

Extensible Dev Tools for Monorepos

65 lines (64 loc) 3.8 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const schematics_1 = require("@angular-devkit/schematics"); const testing_1 = require("@angular-devkit/schematics/testing"); const path_1 = require("path"); const nx_workspace_1 = require("@yolkai/nx-workspace"); const testing_2 = require("@yolkai/nx-workspace/testing"); const testing_3 = require("../../utils/testing"); describe('Update 8.5.0', () => { let tree; let schematicRunner; const jestBuilder = '@yolkai/nx-jest:jest'; const nonJestBuilder = 'something-else'; beforeEach(() => __awaiter(this, void 0, void 0, function* () { tree = schematics_1.Tree.empty(); tree = testing_2.createEmptyWorkspace(tree); schematicRunner = new testing_1.SchematicTestRunner('@yolkai/nx-workspace', path_1.join(__dirname, '../../../migrations.json')); })); describe('When fixing tsconfig.lib.json files', () => { const schematicName = 'fix-tsconfig-lib-json'; it('should not modify non jest projects', () => __awaiter(this, void 0, void 0, function* () { const lib = 'non-jest-lib'; const exclude = [`src/test.ts`, '**/*.spec.ts']; tree = yield testing_3.createLibWithTests(tree, lib, nonJestBuilder, 'test.ts'); tree.create(`/libs/${lib}/tsconfig.lib.json`, JSON.stringify({ exclude })); const result = yield schematicRunner .runSchematicAsync(schematicName, {}, tree) .toPromise(); const tsconfigJson = nx_workspace_1.readJsonInTree(result, `libs/${lib}/tsconfig.lib.json`); expect(tsconfigJson.exclude).toEqual(exclude); })); it('should modify untouched jest projects', () => __awaiter(this, void 0, void 0, function* () { const lib = 'jest-lib'; const exclude = [`src/test.ts`, '**/*.spec.ts']; const expected = ['src/test-setup.ts', '**/*.spec.ts']; tree = yield testing_3.createLibWithTests(tree, lib, jestBuilder, 'test-setup.ts'); tree.create(`/libs/${lib}/tsconfig.lib.json`, JSON.stringify({ exclude })); const result = yield schematicRunner .runSchematicAsync(schematicName, {}, tree) .toPromise(); const tsconfigJson = nx_workspace_1.readJsonInTree(result, `libs/${lib}/tsconfig.lib.json`); expect(tsconfigJson.exclude).toEqual(expected); })); it('should not touch modified jest projects', () => __awaiter(this, void 0, void 0, function* () { const lib = 'modified-jest-lib'; const exclude = [`src/test-modified.ts`, '**/*.spec.ts']; tree = yield testing_3.createLibWithTests(tree, lib, jestBuilder, 'test-modified.ts.ts'); tree.create(`/libs/${lib}/tsconfig.lib.json`, JSON.stringify({ exclude })); const result = yield schematicRunner .runSchematicAsync(schematicName, {}, tree) .toPromise(); const tsconfigJson = nx_workspace_1.readJsonInTree(result, `libs/${lib}/tsconfig.lib.json`); expect(tsconfigJson.exclude).toEqual(exclude); })); }); });