@flopflip/cypress-plugin
Version:
A plugin for Cypress change feature toggles in Cypress runs
1 lines • 2.1 kB
Source Map (JSON)
{"version":3,"file":"index.cjs","names":[],"sources":["../src/plugin.ts","../src/index.ts"],"sourcesContent":["/// <reference types=\"cypress\" />\n\nimport type { TAdapterIdentifiers, TFlags } from '@flopflip/types';\n\ntype TCypressPluginAddCommandOptions = {\n adapterId: TAdapterIdentifiers;\n};\n\ndeclare namespace Cypress {\n interface Chainable {\n updateFeatureFlags: (flags: TFlags) => Chainable;\n }\n}\n\nconst FLOPFLIP_GLOBAL = '__flopflip__';\n\nconst addCommands = (options: TCypressPluginAddCommandOptions) => {\n Cypress.Commands.add(\n // @ts-expect-error Cypress doesn't seem to allow a non any chainable\n 'updateFeatureFlags',\n (flags: TFlags) =>\n cy\n .window()\n .its(FLOPFLIP_GLOBAL)\n .then((flopFlipGlobal) => {\n const flopflipAdapterGlobal = flopFlipGlobal[options.adapterId];\n\n if (!flopflipAdapterGlobal) {\n throw new Error(\n '@flopflip/cypress: namespace or adapter of the passed id does not exist. Make sure you use one and the specified adapter.',\n );\n }\n\n Cypress.log({\n name: 'updateFeatureFlags',\n message: 'Updating @flopflip feature flags.',\n consoleProps: () => ({\n flags,\n }),\n });\n\n flopflipAdapterGlobal?.updateFlags(flags, {\n unsubscribeFlags: true,\n });\n }),\n );\n};\n\nconst install = (_on) => {\n // Add event listeners if needed\n};\n\nexport { addCommands, install };\n","const version = '__@FLOPFLIP/VERSION_OF_RELEASE__';\n\nexport { addCommands, install } from './plugin';\n\nexport { version };\n"],"mappings":";;AAcA,MAAM,kBAAkB;AAExB,MAAM,eAAe,YAA6C;CAChE,QAAQ,SAAS,IAEf,uBACC,UACC,GACG,OAAO,CAAC,CACR,IAAI,eAAe,CAAC,CACpB,MAAM,mBAAmB;EACxB,MAAM,wBAAwB,eAAe,QAAQ;EAErD,IAAI,CAAC,uBACH,MAAM,IAAI,MACR,2HACF;EAGF,QAAQ,IAAI;GACV,MAAM;GACN,SAAS;GACT,qBAAqB,EACnB,MACF;EACF,CAAC;EAED,0BAAA,QAAA,0BAAA,KAAA,KAAA,sBAAuB,YAAY,OAAO,EACxC,kBAAkB,KACpB,CAAC;CACH,CAAC,CACP;AACF;AAEA,MAAM,WAAW,QAAQ,CAEzB;;;AClDA,MAAM,UAAU"}