Skip to content

Commit

Permalink
Fallback for outputDir setting & clean up (#160)
Browse files Browse the repository at this point in the history
* Update index.ts

* fix: Update outputDir for setRecordingPath

* dev: Clean up tabbing after debug

* Update src/index.ts

* fix: Improve outputDir discovery

* chore: Return syntax formatting to initial state

* chore: Clean up lint complaint

* chore: Update tests for change

---------

Co-authored-by: Nicholas "bek" Bekeris <[email protected]>
Co-authored-by: Christian Bromann <[email protected]>
  • Loading branch information
3 people authored Jan 30, 2024
1 parent 1a429c7 commit 3530cdc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ describe('waitForVideosToBeWritten', () => {
.mockImplementationOnce(() => ({ size: 73 } as any))
.mockImplementation(() => ({ size: 512 } as any))
const sleepMock = vi.fn().mockImplementation(sleep)
expect(waitForVideosToBeWritten(videos, 200, sleepMock)).toBe(false)
expect(waitForVideosToBeWritten(videos, 150, sleepMock)).toBe(false)
expect(sleepMock).toBeCalledTimes(2)
})
})
Expand Down
9 changes: 9 additions & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ describe('Video Reporter', () => {
expect(vi.mocked(process.on)).toBeCalledTimes(1)
})

it('sets outputDir to default value if not configured', () => {
const reporter = new VideoReporter({})
reporter.onRunnerStart({
...allureRunner,
config: {}
})
expect(reporter.outputDir).toEqual('_results_')
})

it('should set record to true', () => {
const reporter = new VideoReporter({})
reporter.onRunnerStart(allureRunner)
Expand Down
9 changes: 8 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default class VideoReporter extends WdioReporter {
#allureOutputDir?: string
#allureReporter = new AllureReporterExtension()
#record = true
#defaultOutputDir = '_results_'

screenshotPromises: Promise<void>[] = []
videos: string[] = []
Expand Down Expand Up @@ -61,6 +62,11 @@ export default class VideoReporter extends WdioReporter {
return this.#isDone
}

/**
* set getter to verify values for testing purposes
*/
get outputDir () { return this.#outputDir }

/**
* set getter to verify values for testing purposes
*/
Expand All @@ -85,7 +91,8 @@ export default class VideoReporter extends WdioReporter {
return
}

this.#outputDir = runner.config.outputDir as string
this.#outputDir = this.options.outputDir ?? runner.config.outputDir as string
this.#outputDir = this.#outputDir ?? this.#defaultOutputDir
const sessionId = runner.isMultiremote
? Object.entries(runner.capabilities).map(([, caps]) => caps.sessionId)[0] as string
: runner.sessionId
Expand Down

0 comments on commit 3530cdc

Please sign in to comment.