UNPKG

cumulocity-cypress

Version:
34 lines (33 loc) 1.52 kB
import { to_boolean } from "../../shared/util"; import { C8yDefaultPactPreprocessor, C8yPactPreprocessorDefaultOptions, } from "../../shared/c8ypact"; const { _ } = Cypress; /** * The C8yCypressEnvPreprocessor is a preprocessor implementation that uses * Cypress environment variables to configure C8yPactPreprocessorOptions. * * Options are deep merged in the following order: * - Cypress environment variables * - C8yPactPreprocessorOptions passed to the apply method * - C8yPactPreprocessorOptions passed to the constructor * - Cypress.c8ypact.config value for preprocessor * - C8yPactPreprocessorDefaultOptions */ export class C8yCypressEnvPreprocessor extends C8yDefaultPactPreprocessor { apply(obj, options) { super.apply(obj, this.resolveOptions(options)); } resolveOptions(options) { let preprocessorConfigValue = {}; if (Cypress.c8ypact && typeof Cypress.c8ypact.getConfigValue === "function") { preprocessorConfigValue = Cypress.c8ypact.getConfigValue("preprocessor") ?? {}; } return _.defaults({ ignore: Cypress.env("C8Y_PACT_PREPROCESSOR_IGNORE"), obfuscate: Cypress.env("C8Y_PACT_PREPROCESSOR_OBFUSCATE"), obfuscationPattern: Cypress.env("C8Y_PACT_PREPROCESSOR_PATTERN"), ignoreCase: to_boolean(Cypress.env("C8Y_PACT_PREPROCESSOR_IGNORE_CASE"), true), }, options, this.options, preprocessorConfigValue, C8yPactPreprocessorDefaultOptions); } }