-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cypress init
command to seed / scaffold test files on current directory
#619
Comments
@brian-mann - I am running into this exact (exact) situation right now. I am so glad I found this specific issue entry here! It captures exactly what I'm running into. Is there any ETA? We do not have the desire to gen node_modules per project (at the moment, or even short term) as we will only be utilizing a single version of Node.js and Cypress for the foreseeable future - and technically don't have a "node" project to even work with atm ;) Just getting this working (and I have, via desktop) with our current project - so that we can make the case for using it with our next (and quickly approaching) project that will use node. Or maybe that logic is misapplied. Either way - we went from a "global" installation to a "local" installlation (Cypress CLI was complaining that the .cache folder did not contain a "Cypress" instance) and it worked great. We now do this:
I then do the following, and encounter the "cypress.json" error mentioned here in this issue:
Passing --config (despite no test/spec specified) further underscores this:
|
@brian-mann - Alternatively, just some clear instruction/guidance on how to do this "init" on my own would be so, so helpful as I believe it is the last barricade. Cypress docs - while super awesome (really!) - don't seem to cover what exactly is required for a run to work. It seems there is a lot of reliance on using the UI to select a project (which then generates the required files/folders/etc.) - but as you raised here, we're using CLI entirely. Even just a few quick pointers to get me on my feet would be incredibly appreciated. |
cypress init
commandcypress init
command
Looping the below suggestion in as discussed in #164:
|
|
cypress init
commandcypress init
command to seed / scaffold test files on current directory
This issue was opened in 2017. What is the ETA? Is someone working on it? Also, are there any workarounds in the meantime? |
another use case would be properly setting up
|
@bkucera we could just implement / add this to https://github.com/bahmutov/cly issues - there the progress will be much faster PS: @ollie-o |
I've had to train a few devs on the team to use Cypress, and not having this feature kind of threw them for a loop. It would be more intuitive to explain. "First open the test launcher. Then close the test launcher. Now we can create a test..." I realize that that's not as big of a problem as some other comments on here. All I'm saying is, having this command would really help with our onboarding process. It would also give cypress a better first impression for the uninitiated. |
@Adil-Iqbal president! It is also very nice for the motivation explained here #1929 I can't wait for this #6249 to be reviewed :D |
It's a shame this issue hasn't gotten the attention it deserves. In case anyone else wanders across this ticket, and needs a zero-dependency solution: #!/bin/bash
TEST_FOLDER="./e2e"
PATH_01=("${TEST_FOLDER}/cypress.json" "{ \"video\": false }\n")
PATH_02=("${TEST_FOLDER}/cypress/integration")
PATH_03=("${TEST_FOLDER}/cypress/integration/example.test.js" "context('Example', () => {\n beforeEach(() => { cy.visit('/'); });\n\n it('should have loaded', () => {\n cy.get('title').contains(/.*/);\n });\n});\n")
scaffold=(PATH_01[@] PATH_02[@] PATH_03[@])
if [ ! -f "${!scaffold[0]:0:1}" ]; then
echo "[SCAFFOLD] Cypress test directory"
length=${#scaffold[@]}
for ((i=0; i<$length; i++)); do
path="${!scaffold[i]:0:1}"
contents="${!scaffold[i]:1:1}"
if [[ "${contents}" != "" ]]; then printf "${contents}" > "${path}"; else mkdir -p "${path}"; fi
done
fi TLDR: If the |
What would you like?Cypress should support an automated way of configuring and setting up E2E examples through the command line, for instance using an environment variable. The choice of the full set of "Scaffold example specs" or the single test spec from "Create new spec" should be given. Why is this needed?Currently it is necessary to use This means that there is no straightforward way to automate the setup or update of a running Cypress example project. Instead, manual steps have to be described and carried out. An example of this is in the instructions factory/test-project/README.MD in the cypress-io/cypress-docker-images repo, where it is necessary to combine shell instructions with manual instructions to achieve setup: rm -rf cypress cypress.config.js
npm install cypress@latest --no-package-lock
npx cypress open
Test that scaffolded specs run: npm test |
We no longer seed anything when running
cypress run
on a fresh project.Instead we now error: #618
For that reason we should give users the ability to seed / scaffold out files from the command line instead of using the GUI.
Proposal add a
cypress init
command which does this.Bonus points if we offer an
inquirer
view enabling the user to select what they want to. We could even explain what each one does.The text was updated successfully, but these errors were encountered: