Right now whenever we write a new file that contains Cypress custom commands we add it using Cypress.Commands.add() and then import the file in support/index.js.
But my problem here is that I've 100 such Custom command files, and I cannot load every file everytime I run cypress, because this is going to cause memory issue soon or after
Instead is there a way to import the cypress custom command files in each testcase spec file itself (if needed) instead of support/index.js?
You can import the commands individually in the spec where they are used, the syntax is the same as you are already using in
support/index.js
. I can't think of any reason why not.This would only have an effect if you run the specs individually, obviously.
But I do not think it will cause much difference to the memory usage, since code files have a small footprint (compared to say fixture files).