Adds a unique id to driver source output XML filenames to prevent overwrites#22
Adds a unique id to driver source output XML filenames to prevent overwrites#22mindlapse wants to merge 6 commits intotipsi:masterfrom
Conversation
src/plugins/source.js
Outdated
|
|
||
| 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.
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.
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.
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.
| resolve() | ||
| } | ||
| }) | ||
| return pathToLog |
There was a problem hiding this comment.
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)
|
|
||
| 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.
- 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.