-
Notifications
You must be signed in to change notification settings - Fork 2
Adds a unique id to driver source output XML filenames to prevent overwrites #22
base: master
Are you sure you want to change the base?
Conversation
src/plugins/source.js
Outdated
|
||
export default async function () { | ||
const content = await this.driver.getSource() | ||
|
||
return new Promise((resolve) => { | ||
const pathToLog = path.resolve(process.cwd(), 'appium_source.xml') | ||
const pathToLog = path.resolve(process.cwd(), _.uniqueId('appium_source_')+'.xml') |
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 think better add date+time as unique label.
appium_source_2019-07-22_10:24:12.xml
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.
Also, need to return the final source file name because we put this file into artifacts at a CI.
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.
Okay, I've made both of the changes you've requested - the date format though is ISO8601 standard YYYYMMDDTHHmmss. The ':' character is reserved for filenames on some systems.
@@ -19,5 +20,6 @@ export default async function () { | |||
resolve() | |||
} | |||
}) | |||
return pathToLog |
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.
We return the promise. You can't return the result from promise via return
, you can return some result only via resolve/reject promise methods. Remove return pathToLog
and move it to resolve(pathToLog)
|
||
export default async function () { | ||
const content = await this.driver.getSource() | ||
|
||
return new Promise((resolve) => { | ||
const pathToLog = path.resolve(process.cwd(), 'appium_source.xml') | ||
const pathToLog = path.resolve(process.cwd(), 'appium_source_'+date.format(new Date(), 'YYYYMMDD[T]HHmmss')+'.xml') |
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.
- Sorry, I misled you. We should be able to put the source file with strong naming. We can solve it with some additional param.
export default async function ({ strongSourceFileName = true }) {
You can call await driver.source({ strongSourceFileName: false })
to put unique source files.
2) Let's rename the const to something like sourceFilePath
because it's not logs, it's a source of the page.
3) Don't need to include an external library for one simple action. Use native Date
When there are multiple test failures, this change will save each captured source to a separate file.