@o3r/testing
Version:
The module provides testing (e2e, unit test) utilities to help you build your own E2E pipeline integrating visual testing.
49 lines • 2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ngGeneratePlaywrightScenario = 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 scenario to an Otter project
* @param options
*/
function ngGeneratePlaywrightScenarioFn(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 scenario');
}
return tree;
};
const scenarioName = core_1.strings.capitalize(core_1.strings.camelize(options.name));
/**
* Generates playwright scenario file.
* @param tree File tree
* @param context Context of the rule
*/
const generateFiles = (tree, context) => {
const scenarioPath = (0, schematics_2.getDestinationPath)('@o3r/testing:playwright-scenario', options.path, tree, options.projectName);
const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./templates'), [
(0, schematics_1.template)({
...core_1.strings,
...options,
scenarioName
}),
(0, schematics_1.renameTemplateFiles)(),
(0, schematics_1.move)(scenarioPath)
]);
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 scenario to an Otter project
* @param options
*/
exports.ngGeneratePlaywrightScenario = (0, schematics_2.createOtterSchematic)(ngGeneratePlaywrightScenarioFn);
//# sourceMappingURL=index.js.map