https://cypress.io logo
Create a library containing commands that need a p...
# i-need-help
m
Hi people, in my company, we want to create a cross project solution, using commands packed in libraries. One of the libraries needs to use the xpath plugin, and I wanted to ask if there's any way to create the library in such a way that, when people install it, they don't need to import the plugin manually into their e2e.js file, or if there's no way around it. Sorry if this is more a JS question, but, since it involves Cypress, I thought it'd be a good idea to ask here. Thank you all for your attention!
g
you would still need some top-level import, at least your library from the project's support file
m
I did a bit of work with other command libraries, where people would need to do something like:
Copy code
javascript
// cypress/support/libraryCommands.js

import register-command from 'command-library';

register-command()
So, the thing is that people will need to do this, and also import the plugin into the e2e.js config file?
g
so yeah, and this is a common pattern. Support vs config file - it depends on what the plugin needs. Different requirements and plugin registrations possible are shown in my https://cypress.tips/courses/cypress-plugins (paid) course