What is the difference between cypress.json and cypress.config.js? - cypress

What is the difference between the files cypress.json and cypress.config.js configuration files in Cypress?

According to the Cypress configuration doc, cypress.config.js is used is Cypress version 10 and higher and cypress.json is used in earlier versions.

Related

No spec files found when running Cypress using scripts in package.json

I am trying to use script aliases in the package.json file.
In order for something like this to open the test runner,
"cy:open:prod": "cypress open --env ENV=production",
I run the command npm run cy:open:prod in the command line in the same folder that package.json is located.
The script runs and opens the test runner, however no spec files are found.
In all the examples I have found it describes this approach. Is there something I am missing in configuation to point it to where my spec files are?
Thanks in advance.
There is nothing basically wrong with the scripts in package.json, they look normal and would not cause the problem you mention.
I suggest you check the specPattern setting in configuration, it should match the naming convention you have chosen to use for your specs.
See e2e settings for more details.
Of you still have trouble with it, start a new project and let Cypress set the configuration for you, it will automatically match up the specPattern to the default value.

Script for open cypress test runner

There are multiple projects inside our repo.
Eg.
MainProject/
SubProject_1/
SubProject_2/
After I installed cypress, "Cypress" folders were created for each project.
MainProject/
Cypress
SubProject_1/
Cypress
SubProject_2/
Cypress
Now in package.json file I've got;
Script
{
"cypress:open": "cypress open",
}
When I run npm run cypress:open, it opens up UI for root directory. Which is;
MainProject/
Cypress
If I want to open cypress for different folder as below, how should I try modify the script ?
SubProject_1/
Cypress
Please note that, I've got cypress v10.
When I run Cypress open --project ./SubProject_1/Cypress, it created a folder /SubProject_1/Cypress.
Thanks
I think you want to specify the config file for the particular project,
See Specifying an Alternative Config File
"open:sub1": "cypress open --config-file SubProject_1/cypress.config.js"
Each project config would specify the folders relative to that project.

Is there a way to specify which tests to run (from multiple files) in Cypress?

I'm using Javascript with Cypress framework to automate tests.
How do I mark tests as tier1 , tier 2 etc. so that I could run only tests marked tier1 or tier2 ?
You can group them by folders, and then use the ignoreTestFiles and testFiles config params to ignore or use them, according to your needs.
You will have to use the route that matches all the tests inside the folder.
For example, you have three folders inside the integration folder called Tier1, Tier2 and Tier3. To indicate that Cypress should ignore tests inside Tier1 and only use Tier2 and Tier3 you have to add to your config:
ignoreTestFiles: '**/Tier1/*.js'
Or if you prefer:
testFiles: ['**/Tier2/*.js', '**/Tier3/*.js']
To know more about config params take a look to the Cypress docs: https://docs.cypress.io/guides/references/configuration#Folders-Files
Set up different subfolders in your integration folder in Cypress, called "tier1", tier2", tier3"
npx cypress run will still run all subfolders
"npx cypress run --spec "cypress/integration/{subfolder}/*-spec.js" will run all tests in a specific subfolder

How can I enable Gradle file system watching persistently?

Gradle has this new feature that listen to file system events instead of touching the filesystem to detect changes to local files.
It can be enabled on the command line with --watch-fs. How can it be enabled persistently in a file that I would check in source control?
As of today, with Gradle 6.5 you can enable the experimental feature by putting the following in gradle.properties in the project root, or in your ~/.gradle/gradle.properties file:
org.gradle.unsafe.watch-fs=true
The feature will eventually be enabled by default, and the property name will change (losing the unsafe part).
Blog post from May 2020 gives the property as this:
org.gradle.vfs.watch=true
https://blog.gradle.org/introducing-file-system-watching
and it's confirmed on the Build Properties list here (for Gradle 7.0 and up):
https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties

Error: more than one config file specified in protractor

I'm trying to configure visual studio to run protractor tests using this tutorial http://goo.gl/lsjMEi
I've included node_modules\protractor\lib\cli.js into my project and set is as node.js startup file, and in my project propreties, i've defined my conf.js as script agruments. When i run my project, i get this message:
Error: more than one config file specified
This is my project structure:
I found the problem. I've set in project properties the whole path of conf.js insted just conf.js.
Another possible solution is to make sure you add '--' before any parameters.
protractor config param="foo" //This will fail with 'more than one config file'
protractor config --param="foo" //This will succeed

Resources