Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Minor developer usability improvement #156

Closed
stocksr started this conversation in Ideas
Discussion options

in the Getting Started guide there is this example cypress.config.ts file

// typescript / ES6
import { defineConfig } from 'cypress';
import { initPlugin } from '@frsource/cypress-plugin-visual-regression-diff/plugins';
export default defineConfig({
 // initPlugin must be called in the section where it is used: e2e or component
 e2e: {
 setupNodeEvents(on, config) {
 initPlugin(on, config);
 }
 },
 component: {
 setupNodeEvents(on, config) {
 initPlugin(on, config);
 }
 }
});

would it be possible to rename the initPlugin method to initVisualRegressionPlugin or something like that that includes the name of the plugin?
reason: if I have several plugins installed this line initPlugin(on, config); on it's own does not provide any context as to which plugin it is initializing.

I know this would be a breaking change so we might have to wait for the next major release and I am also aware that I can "Solve" this by aliasing the import so a couple of questions:

  1. Is it worth changing this given the workarounds below?
  2. Is it worth changing the guide to use one of the workarounds below?

Work around 1
import { initPlugin as initVisualRegressionPlugin } from '@frsource/cypress-plugin-visual-regression-diff/dist/plugins';
with the corresponding setupNodeEvents change of
initVisualRegressionPlugin(on, config);
Work around 2
import * as frsourceVisualRegressionDiff from '@frsource/cypress-plugin-visual-regression-diff/dist/plugins';
and
frsourceVisualRegressionDiff.initPlugin(on, config);

You must be logged in to vote

Replies: 1 comment 2 replies

Comment options

I would actually propose to just use workaround no 1 as an official way to overcome this issue. IMO it's nicer to try to have similar API for all of the plugins (ergo - having the same initPlugin method in every package), especially when there is a in-build language feature to rename imported method.

But I think we can rewrite docs a bit to actually encourage using import { initPlugin as initVisualRegressionPlugin } syntax as it is more expressive

You must be logged in to vote
2 replies
Comment options

BTW. you should be able to import initPlugin from @frsource/cypress-plugin-visual-regression-diff/plugins and not @frsource/cypress-plugin-visual-regression-diff/dist/plugins (see the dist part now removed) in ES-compatible bundlers (for sure in Vite, but I think webpack also should pick it up)

Comment options

On the v4 branch I've updated README to propose using as initVisualRegressionPlugin syntax

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /