https://cypress.io logo
Can I import faker plugin globally rather than in ...
# i-need-help
t
Currently we're using faker package: https://www.npmjs.com/package/@faker-js/faker Following their instructions, we are using this code at the top of each spec.cy.js file which allows us to use faker in that one spec:
Copy code
js
import { faker } from '@faker-js/faker';
Is it possible to import this globally without needing to put it on every spec file? I've tried adding it to the e2e.js but it doesn't seem to work. Thanks
s
You can try this
Add the import in your e2e.js file
then you can use faker in your test
your IDE will however automatically do the import for you
In the end you will still need to have the import but you will not need to add it manually
t
I think that's working, so I had to add it using the CommonJS method. Thank you! 🙂
2 Views