-
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
feat: Scope slowTestThreshold to specific testing types #20569
feat: Scope slowTestThreshold to specific testing types #20569
Conversation
Thanks for taking the time to open a PR!
|
Test summaryRun details
View run in Cypress Dashboard ➡️ FlakinessThis comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few changes that I don't understand.
Also, can you add a test for migration that actually moves the value from the root of the json file to the e2e tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code seems 💯 but why are we scoping this in the first place?
I also don't see this documented anywhere (like here: https://www.notion.so/cypressdx/Changes-for-10-0-0-1dca213837b84d6ea297c2d12c615f3a#d80e7d92e76c41b9b56673acf48f93cf).
Sorry to drop this here - just wanting to clarify whether
- DX decided this and forgot to document it
- Someone else decided this without it going through the correct process (usually DX should approve config changes)
cc @cowboy perhaps, master of the config changes document.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BlueWinds Can you open a PR against the unification docs? The slowTestThreshold needs to be moved into the Testing-Type Specific Options for config: https://deploy-preview-4186--cypress-docs.netlify.app/guides/references/configuration#Testing-Type-Specific-Options
…owTestThreshold-by-testing-type
Done in cypress-io/cypress-documentation#4388. Was on my TODO list, is why I didn't check it off in the PR Tasks checklist. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One comment! We don't want to add component
to the migrated config if you haven't previously used component testing; we should have a test where hasComponentTesting: false
, which means "this user has not used component testing before".
snapshot(generatedConfig) | ||
}) | ||
|
||
it('should create only a component entry when no e2e specs are detected', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lmiller1990 - I added this test and left the one below it, testing the case where only one testing type is detected. The snapshots for these two test display only component
and only e2e
blocks respectively.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
packages/config/lib/options.ts
Outdated
errorKey: 'CONFIG_FILE_INVALID_ROOT_CONFIG', | ||
isWarning: false, | ||
testingTypes: ['component', 'e2e'], | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On this PR, @estrada9166 added/updated typescript tests for baseUrl, which is another invalid root-level configuration option. Might be a good idea to add in tests for this option. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at those tests, it doesn't look like we test every config value that way, just a few examples selected to show Cypress.config()
reflects the typings of values that can be retrieved from it. We already have Cypress.config('taskTimeout') // $ExpectType number
demonstrating that numbers are done correctly, and don't think slowTestThreshold needs to be added there.
Interesting though, I'd never seen that file before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like it can be added to verify the types are working as expected and/or throws an error when used incorrectly. i.e.
// cypress.config.js
{
slowTestThreshold: 200 // expect error as unsupported type
}```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cypress.config('slowTestThreshold', 1000)
is not an error, nor should it be - in the resolved config, slowTestThreshold
can be at the top level, and it can be changed on a per-test basis (unlike baseUrl). It's only in the config file that it can't be top-level.
const ext = '**/*.cy.{js,jsx,ts,tsx}' | ||
const isDefaultE2E = key === 'e2e' && specPattern === `cypress/e2e/${ext}` | ||
const isDefaultCT = key === 'component' && specPattern === ext |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a change for this PR, just in general..would love to see these default values pulled from the config packages instead of hard-coded here
case 'supportFile': | ||
return { | ||
...acc, | ||
e2e: { ...acc.e2e, supportFile: val }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm sorry @BlueWinds...sanity check though, currently in 9x the support file is shared between e2e and component right? Shouldn't this map to both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, it does sound like it should to me. @lmiller1990, thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I asked exactly the same question at the time - Brian said nope, we just map to e2e.supportFile
. During CT setup we will create a new file called cypress/support/component.js
.
(Yes - this means that CT users will have some small inconvenience during migration from 9.x -> 10.x. But CT users are in the minority).
You can ping in the migration channel if you feel this is weird and should be revisited.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lmiller1990 I did ask there as well. No response yet.
…owTestThreshold-by-testing-type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emilyrohrbough pointed out lots of potential small improvements we could make, I don't see those as blockers to this PR, since those were not changes introduced here. Definitely good to capture those in Jira tickets.
As for the actual code and PR, my comments have been addressed. ✅
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
User facing changelog
slowTestThreshold
is no longer a valid global configuration option, and must be defined per testing type. This will be done as part of the automatic config migration where possible.Additional details
If a user in 9.x has defined a custom slowTestThreshold at the global level:
After this change, migrate to 10.x will update their config to this instead:
If they only have one testing type set up (eg, most users with only e2e tests), they will get the shorter version with slowTestThreshold moved inside their testing type:
How has the user experience changed?
PR Tasks
cypress-documentation
? TODOtype definitions
?cypress.schema.json
?