UNPKG

@ockilson/ng-jest

Version:

Schematic to setup jest for angular/cli projects

70 lines 2.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const schematics_1 = require("@angular-devkit/schematics"); const testing_1 = require("@angular-devkit/schematics/testing"); const collectionPath = require.resolve('./collection.json'); describe('jest setup', () => { const testRunner = new testing_1.SchematicTestRunner('ng-jest', collectionPath); const workspaceOptions = { name: 'workspace', newProjectRoot: 'projects', version: '7.0.5', }; describe('new application', () => { const appOptions = { name: 'bar', inlineStyle: false, inlineTemplate: false, routing: false, style: 'css', skipTests: false, skipPackageJson: false, }; let appTree; beforeEach(() => { appTree = testRunner.runExternalSchematic('@schematics/angular', 'workspace', workspaceOptions); }); it('fails with missing tree', () => { expect(() => testRunner.runSchematic('application', { name: "test" }, schematics_1.Tree.empty())).toThrow(); }); it('fails with missing params', () => { expect(() => testRunner.runSchematic('application', {}, appTree)).toThrowError(); }); it('works', () => { const tree = testRunner.runSchematic('application', appOptions, appTree); expect(tree.files).not.toContain("/projects/bar/src/app/test/test.ts"); expect(tree.files).not.toContain("/projects/bar/karma.conf.js"); }); }); describe('new library', () => { const appOptions = { name: 'bar', inlineStyle: false, inlineTemplate: false, routing: false, style: 'css', skipTests: false, skipPackageJson: false, }; let appTree; beforeEach(() => { appTree = testRunner.runExternalSchematic('@schematics/angular', 'workspace', workspaceOptions); }); it('fails with missing tree', () => { expect(() => testRunner.runSchematic('library', { name: "test" }, schematics_1.Tree.empty())).toThrow(); }); it('fails with missing params', () => { expect(() => testRunner.runSchematic('library', {}, appTree)).toThrowError(); }); it('works', () => { const tree = testRunner.runSchematic('library', appOptions, appTree); expect(tree.files).not.toContain("/projects/bar/src/lib/test/test.ts"); expect(tree.files).not.toContain("/projects/bar/karma.conf.js"); }); }); }); //# sourceMappingURL=index.spec.js.map