-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add internal log group API and update log group styles (#20857)
Co-authored-by: Matt Henkes <mjhenkes@gmail.com>
- Loading branch information
1 parent
ee7495f
commit d0fc93b
Showing
22 changed files
with
701 additions
and
125 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,42 @@ | ||
import { $Command } from '../cypress/command' | ||
import $errUtils from '../cypress/error_utils' | ||
|
||
export default (Cypress, userOptions: Cypress.LogGroup.Config, fn: Cypress.LogGroup.ApiCallback) => { | ||
const cy = Cypress.cy | ||
|
||
const shouldEmitLog = userOptions.log === undefined ? true : userOptions.log | ||
|
||
const options: Cypress.InternalLogConfig = { | ||
...userOptions, | ||
instrument: 'command', | ||
groupStart: true, | ||
emitOnly: !shouldEmitLog, | ||
} | ||
|
||
const log = Cypress.log(options) | ||
|
||
if (!_.isFunction(fn)) { | ||
$errUtils.throwErrByPath('group.missing_fn', { onFail: log }) | ||
} | ||
|
||
// An internal command is inserted to create a divider between | ||
// commands inside group() callback and commands chained to it. | ||
const restoreCmdIndex = cy.state('index') + 1 | ||
|
||
const endLogGroupCmd = $Command.create({ | ||
name: 'end-logGroup', | ||
injected: true, | ||
}) | ||
|
||
const forwardYieldedSubject = () => { | ||
if (log) { | ||
log.endGroup() | ||
} | ||
|
||
return endLogGroupCmd.get('prev').get('subject') | ||
} | ||
|
||
cy.queue.insert(restoreCmdIndex, endLogGroupCmd.set('fn', forwardYieldedSubject)) | ||
|
||
return fn(log) | ||
} |
This file contains 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 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 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 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 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 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,27 @@ | ||
// The type declarations for Cypress Log Group & the corresponding configuration permutations | ||
declare namespace Cypress { | ||
declare namespace LogGroup { | ||
type ApiCallback = (log: Cypress.Log) => Chainable<S> | ||
type LogGroup = (cypress: Cypress.Cypress, options: Partial<LogGroupConfig>, callback: LogGroupCallback) => Chainable<S> | ||
|
||
interface Config { | ||
// the JQuery element for the command. This will highlight the command | ||
// in the main window when debugging | ||
$el?: JQuery | ||
// whether or not to emit a log to the UI | ||
// when disabled, child logs will not be nested in the UI | ||
log?: boolean | ||
// name of the group - defaults to current command's name | ||
name?: string | ||
// additional information to include in the log | ||
message?: string | ||
// timeout of the group command - defaults to defaultCommandTimeout | ||
timeout?: number | ||
// the type of log | ||
// system - log generated by Cypress | ||
// parent - log generated by Command | ||
// child - log generated by Chained Command | ||
type?: Cypress.InternalLogConfig['type'] | ||
} | ||
} | ||
} |
This file contains 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,62 @@ | ||
// The type declarations for Cypress Logs & the corresponding configuration permutations | ||
declare namespace Cypress { | ||
interface Cypress { | ||
log(options: Partial<LogConfig | InternalLogConfig>): Log | undefined | ||
} | ||
|
||
interface Log extends Log { | ||
set<K extends keyof LogConfig | InternalLogConfig>(key: K, value: LogConfig[K]): InternalLog | ||
set(options: Partial<LogConfig | InternalLogConfig>) | ||
groupEnd(): void | ||
} | ||
|
||
interface InternalLogConfig { | ||
// defaults to command | ||
instrument?: 'agent' | 'command' | 'route' | ||
// name of the log | ||
name?: string | ||
// the name override for display purposes only | ||
displayName?: string | ||
// additional information to include in the log if not overridden | ||
// the render props message | ||
// defaults to command arguments for command instrument | ||
message?: string | Array<string> | any[] | ||
// whether or not the xhr route had a corresponding response stubbed out | ||
isStubbed?: boolean | ||
alias?: string | ||
aliasType?: 'agent' | 'route' | 'primitive' | 'dom' | undefined | ||
commandName?: string | ||
// the JQuery element for the command. This will highlight the command | ||
// in the main window when debugging | ||
$el?: JQuery | ||
// whether or not to show the log in the Reporter UI or only | ||
// store the log details on the command and log manager | ||
emitOnly?: boolean | ||
// whether or not to start a new log group | ||
groupStart?: boolean | ||
// the type of log | ||
// system - log generated by Cypress | ||
// parent - log generated by Command | ||
// child - log generated by Chained Command | ||
type?: 'system' | 'parent' | 'child' | ((current: State['state']['current'], subject: State['state']['subject']) => 'parent' | 'child') | ||
// whether or not the generated log was an event or command | ||
event?: boolean | ||
method?: string | ||
url?: string | ||
status?: number | ||
// the number of xhr responses that occurred. This is only applicable to | ||
// logs defined with instrument=route | ||
numResponses?: number | ||
response?: string | object | ||
// provide the content to display in the dev tool's console when a log is | ||
// clicked from the Reporter's Command Log | ||
consoleProps?: () => ObjectLike | ||
renderProps?: () => { | ||
indicator?: 'aborted' | 'pending' | 'successful' | 'bad' | ||
message?: string | ||
} | ||
browserPreRequest?: any | ||
// timeout of the group command - defaults to defaultCommandTimeout | ||
timeout?: number | ||
} | ||
} |
This file contains 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 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 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
Oops, something went wrong.
d0fc93b
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.
Circle has built the
linux x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
d0fc93b
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.
Circle has built the
darwin x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
d0fc93b
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.
Circle has built the
win32 x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally: