-
-
Notifications
You must be signed in to change notification settings - Fork 22
-
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:
- Is it worth changing this given the workarounds below?
- 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);
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment 2 replies
-
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
Beta Was this translation helpful? Give feedback.
All reactions
-
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)
Beta Was this translation helpful? Give feedback.
All reactions
-
On the v4
branch I've updated README to propose using as initVisualRegressionPlugin
syntax
Beta Was this translation helpful? Give feedback.