@flopflip/cypress-plugin
Version:
A plugin for Cypress change feature toggles in Cypress runs
37 lines (32 loc) • 1.19 kB
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true});// src/plugin.ts
var FLOPFLIP_GLOBAL = "__flopflip__";
var addCommands = (options) => {
Cypress.Commands.add(
// @ts-expect-error Cypress doesn't seem to allow a non any chainable
"updateFeatureFlags",
(flags) => cy.window().its(FLOPFLIP_GLOBAL).then((flopFlipGlobal) => {
const flopflipAdapterGlobal = flopFlipGlobal[options.adapterId];
if (!flopflipAdapterGlobal) {
throw new Error(
"@flopflip/cypress: namespace or adapter of the passed id does not exist. Make sure you use one and the specified adapter."
);
}
Cypress.log({
name: "updateFeatureFlags",
message: "Updating @flopflip feature flags.",
consoleProps: () => ({
flags
})
});
flopflipAdapterGlobal == null ? void 0 : flopflipAdapterGlobal.updateFlags(flags, {
unsubscribeFlags: true
});
})
);
};
var install = (_on) => {
};
// src/index.ts
var version = "__@FLOPFLIP/VERSION_OF_RELEASE__";
exports.addCommands = addCommands; exports.install = install; exports.version = version;
//# sourceMappingURL=index.cjs.map