@flopflip/cypress-plugin
Version:
A plugin for Cypress change feature toggles in Cypress runs
37 lines (36 loc) • 1.07 kB
JavaScript
// 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__";
export {
addCommands,
install,
version
};
//# sourceMappingURL=index.js.map