UNPKG

@o3r/testing

Version:

The module provides testing (e2e, unit test) utilities to help you build your own E2E pipeline integrating visual testing.

49 lines 1.98 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ngGeneratePlaywrightSanity = void 0; const core_1 = require("@angular-devkit/core"); const schematics_1 = require("@angular-devkit/schematics"); const schematics_2 = require("@o3r/schematics"); /** * Add a Playwright sanity to an Otter project * @param options */ function ngGeneratePlaywrightSanityFn(options) { const isApplication = (tree /* , context: SchematicContext*/) => { const workspaceProject = options.projectName ? (0, schematics_2.getWorkspaceConfig)(tree)?.projects[options.projectName] : undefined; if (!workspaceProject) { throw new schematics_2.O3rCliError('Cannot create a playwright sanity'); } return tree; }; const sanityName = core_1.strings.capitalize(core_1.strings.camelize(options.name)); /** * Generates playwright sanity file. * @param tree File tree * @param context Context of the rule */ const generateFiles = (tree, context) => { const sanityPath = (0, schematics_2.getDestinationPath)('@o3r/testing:playwright-sanity', options.path, tree, options.projectName); const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./templates'), [ (0, schematics_1.template)({ ...core_1.strings, ...options, sanityName }), (0, schematics_1.renameTemplateFiles)(), (0, schematics_1.move)(sanityPath) ]); const rule = (0, schematics_1.mergeWith)(templateSource, schematics_1.MergeStrategy.Error); return rule(tree, context); }; return (0, schematics_1.chain)([ isApplication, generateFiles ]); } /** * Add a Playwright sanity to an Otter project * @param options */ exports.ngGeneratePlaywrightSanity = (0, schematics_2.createOtterSchematic)(ngGeneratePlaywrightSanityFn); //# sourceMappingURL=index.js.map