-
Notifications
You must be signed in to change notification settings - Fork 3.4k
feat: scaffold and register cy.mount command for CT #20933
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
edf5595
fix: small ui tweaks for switch testing type (#20901)
ZachJW34 1d2d6a4
fix: add missing component-index.html (#20926)
ZachJW34 f54860c
Merge remote-tracking branch 'origin/10.0-release' into lmiller1990/U…
lmiller1990 06fdf47
move files from data-context to scaffold-config
lmiller1990 c3d8b98
dynamically modify support file based on selected framework
lmiller1990 a708787
scaffold correct supportFile for CT based on framework
lmiller1990 d304fba
update scaffolded files
lmiller1990 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import type { CodeLanguage } from '@packages/types' | ||
| import dedent from 'dedent' | ||
|
|
||
| const COMMAND_TYPES = dedent` | ||
| // | ||
| // declare global { | ||
| // namespace Cypress { | ||
| // interface Chainable { | ||
| // login(email: string, password: string): Chainable<void> | ||
| // drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element> | ||
| // dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element> | ||
| // visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element> | ||
| // } | ||
| // } | ||
| // } | ||
| ` | ||
|
|
||
| export function commandsFileBody (language: CodeLanguage['type']) { | ||
| return dedent` | ||
| ${language === 'ts' ? '/// <reference types="cypress" />' : ''} | ||
| // *********************************************** | ||
| // This example commands.${language} shows you how to | ||
| // create various custom commands and overwrite | ||
| // existing commands. | ||
| // | ||
| // For more comprehensive examples of custom | ||
| // commands please read more here: | ||
| // https://on.cypress.io/custom-commands | ||
| // *********************************************** | ||
| // | ||
| // | ||
| // -- This is a parent command -- | ||
| // Cypress.Commands.add('login', (email, password) => { ... }) | ||
| // | ||
| // | ||
| // -- This is a child command -- | ||
| // Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) | ||
| // | ||
| // | ||
| // -- This is a dual command -- | ||
| // Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) | ||
| // | ||
| // | ||
| // -- This will overwrite an existing command -- | ||
| // Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) | ||
| ${language === 'ts' ? COMMAND_TYPES : ''} | ||
| ` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| /* eslint-disable padding-line-between-statements */ | ||
| // created by autobarrel, do not modify directly | ||
|
|
||
| export * from './commandFile' | ||
| export * from './dependencies' | ||
| export * from './detect' | ||
| export * from './frameworks' | ||
| export * from './supportFile' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| import type { CodeLanguage } from '@packages/types' | ||
| import dedent from 'dedent' | ||
| import type { WizardFrontendFramework } from '.' | ||
|
|
||
| export function supportFileE2E (language: CodeLanguage['type']) { | ||
| return dedent` | ||
| // *********************************************************** | ||
| // This example support/e2e.${language} is processed and | ||
| // loaded automatically before your test files. | ||
| // | ||
| // This is a great place to put global configuration and | ||
| // behavior that modifies Cypress. | ||
| // | ||
| // You can change the location of this file or turn off | ||
| // automatically serving support files with the | ||
| // 'supportFile' configuration option. | ||
| // | ||
| // You can read more here: | ||
| // https://on.cypress.io/configuration | ||
| // *********************************************************** | ||
|
|
||
| // Import commands.js using ES2015 syntax: | ||
| import './commands' | ||
|
|
||
| // Alternatively you can use CommonJS syntax: | ||
| // require('./commands') | ||
| ` | ||
| } | ||
|
|
||
| export function supportFileComponent (language: CodeLanguage['type'], framework: WizardFrontendFramework) { | ||
| const supportFileTemplate = dedent` | ||
| // *********************************************************** | ||
| // This example support/component.${language} is processed and | ||
| // loaded automatically before your test files. | ||
| // | ||
| // This is a great place to put global configuration and | ||
| // behavior that modifies Cypress. | ||
| // | ||
| // You can change the location of this file or turn off | ||
| // automatically serving support files with the | ||
| // 'supportFile' configuration option. | ||
| // | ||
| // You can read more here: | ||
| // https://on.cypress.io/configuration | ||
| // *********************************************************** | ||
|
|
||
| // Import commands.js using ES2015 syntax: | ||
| import './commands' | ||
|
|
||
| // Alternatively you can use CommonJS syntax: | ||
| // require('./commands') | ||
| ` | ||
|
|
||
| const exampleUse = dedent` | ||
| // Example use: | ||
| // cy.mount(${framework.mountModule === 'cypress/react' ? '<MyComponent />' : 'MyComponent'}) | ||
| ` | ||
|
|
||
| const NEWLINE = '\n\n' | ||
|
|
||
| if (language === 'ts') { | ||
| const registerMount = dedent` | ||
| import { mount } from '${framework.mountModule}' | ||
| import type { MountReturn } from '${framework.mountModule}' | ||
|
|
||
| // Augment the Cypress namespace to include type definitions for | ||
| // your custom command. | ||
| // Alternatively, can be defined in cypress/support/component.d.ts | ||
| // with a <reference path="./component" /> at the top of your spec. | ||
| declare global { | ||
| namespace Cypress { | ||
| interface Chainable { | ||
| mount: typeof mount | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Cypress.Commands.add('mount', mount) | ||
| ` | ||
|
|
||
| return [supportFileTemplate, registerMount, exampleUse].join(NEWLINE) | ||
| } | ||
|
|
||
| const registerMount = dedent` | ||
| import { mount } from '${framework.mountModule}' | ||
|
|
||
| Cypress.Commands.add('mount', mount) | ||
| ` | ||
|
|
||
| return [supportFileTemplate, registerMount, exampleUse].join(NEWLINE) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Moved to
packages/scaffold-config, trying to consolidate all the scaffolding code in one place.