-
Notifications
You must be signed in to change notification settings - Fork 0
Build Unification - WDIO Mocha, Cucumber, Jasmine #15
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
base: v8
Are you sure you want to change the base?
Changes from 25 commits
f360343
5b644fc
1e5ee92
9ca7bda
29081fd
52e6ae7
247d80b
cbbcd86
17e5fe6
c9c6757
e4e6bf3
91dd23e
8a130c7
de2027f
8a18216
4e8a83d
a9078af
4e1bea4
dba7ebe
d96fc13
c03901e
7d570f7
8648184
294cfa3
c718e19
2585133
273b446
77fc2b6
a5fbc0f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,7 @@ | ||
| import InsightsHandler from '../insights-handler.js' | ||
| import TestReporter from '../reporter.js' | ||
| import { PercyLogger } from './PercyLogger.js' | ||
| import { isUndefined } from '../util.js' | ||
|
|
||
| const tryRequire = async function (pkg: string, fallback: any) { | ||
| try { | ||
|
|
@@ -17,9 +20,19 @@ let snapshotHandler = (...args: any[]) => { | |
| PercyLogger.error('Unsupported driver for percy') | ||
| } | ||
| if (percySnapshot) { | ||
| snapshotHandler = (browser: WebdriverIO.Browser | WebdriverIO.MultiRemoteBrowser, name: string) => { | ||
| snapshotHandler = (browser: WebdriverIO.Browser | WebdriverIO.MultiRemoteBrowser, snapshotName: string, options?: any) => { | ||
| if (process.env.PERCY_SNAPSHOT === 'true') { | ||
| return percySnapshot(browser, name) | ||
| let { name, uuid } = InsightsHandler._currentTest | ||
amaanbs marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (isUndefined(name)) { | ||
| ({ name, uuid } = TestReporter._currentTest) | ||
amaanbs marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| options ||= {} | ||
| options = { | ||
| ...options, | ||
| testCase: name || '', | ||
| thTestCaseExecutionId: uuid || '', | ||
| } | ||
| return percySnapshot(browser, snapshotName, options) | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -30,7 +43,28 @@ let screenshotHandler = async (...args: any[]) => { | |
| PercyLogger.error('Unsupported driver for percy') | ||
| } | ||
| if (percySnapshot && percySnapshot.percyScreenshot) { | ||
| screenshotHandler = percySnapshot.percyScreenshot | ||
| screenshotHandler = (browser: WebdriverIO.Browser | WebdriverIO.MultiRemoteBrowser | string, screenshotName: any, options?: any) => { | ||
|
||
| let { name, uuid } = InsightsHandler._currentTest | ||
| if (isUndefined(name)) { | ||
| ({ name, uuid } = TestReporter._currentTest) | ||
| } | ||
| if (!browser || typeof browser === 'string') { | ||
| screenshotName ||= {} | ||
| screenshotName = { | ||
| ...screenshotName, | ||
| testCase: name || '', | ||
| thTestCaseExecutionId: uuid || '', | ||
| } | ||
| } else { | ||
| options ||= {} | ||
| options = { | ||
| ...options, | ||
| testCase: name || '', | ||
| thTestCaseExecutionId: uuid || '', | ||
| } | ||
| } | ||
| return percySnapshot.percyScreenshot(browser, screenshotName, options) | ||
| } | ||
| } | ||
| export const screenshot = screenshotHandler | ||
|
|
||
|
|
@@ -39,6 +73,27 @@ let screenshotAppHandler = async (...args: any[]) => { | |
| PercyLogger.error('Unsupported driver for percy') | ||
| } | ||
| if (percyAppScreenshot) { | ||
| screenshotAppHandler = percyAppScreenshot | ||
| screenshotAppHandler = (driverOrName: any, nameOrOptions?: any, options?: any) => { | ||
|
||
| let { name, uuid } = InsightsHandler._currentTest | ||
| if (isUndefined(name)) { | ||
| ({ name, uuid } = TestReporter._currentTest) | ||
| } | ||
| if (!driverOrName || typeof driverOrName === 'string') { | ||
| nameOrOptions ||= {} | ||
| nameOrOptions = { | ||
| ...nameOrOptions, | ||
| testCase: name || '', | ||
| thTestCaseExecutionId: uuid || '', | ||
| } | ||
| } else { | ||
| options ||= {} | ||
| options = { | ||
| ...options, | ||
| testCase: name || '', | ||
| thTestCaseExecutionId: uuid || '', | ||
| } | ||
| } | ||
| return percyAppScreenshot(driverOrName, nameOrOptions, options) | ||
| } | ||
| } | ||
| export const screenshotApp = screenshotAppHandler | ||
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.
Please add a line after import statements
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.
Done