Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/pr-263.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this file needed?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is automatically added for release notes purposes and get removed

"@wdio/browserstack-service": patch
---

- Fixed `ETXTBSY: text file is busy, open '~/.browserstack/percy'` crashes on Linux when Percy is enabled.
15 changes: 10 additions & 5 deletions packages/browserstack-service/src/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,11 +515,16 @@ export default class BrowserstackLauncherService implements Services.ServiceInst
try {
const bestPlatformPercyCaps = getBestPlatformForPercySnapshot(capabilities as Capabilities.TestrunnerCapabilities)
this._percyBestPlatformCaps = bestPlatformPercyCaps as WebdriverIO.Capabilities
process.env[BROWSERSTACK_PERCY] = 'false'
await this.setupPercy(this._options, this._config, {
projectName: this._projectName
})
this._updateBrowserStackPercyConfig()
// The CLI runs Percy from the same path; re-downloading over the running executable fails with ETXTBSY on Linux.
if (BrowserstackCLI.getInstance().isRunning()) {
PercyLogger.debug('Percy is managed by the BrowserStack CLI, skipping service-side Percy setup')
} else {
process.env[BROWSERSTACK_PERCY] = 'false'
await this.setupPercy(this._options, this._config, {
projectName: this._projectName
})
this._updateBrowserStackPercyConfig()
}
} catch (err) {
PercyLogger.error(`Error while setting up Percy ${err}`)
}
Expand Down
26 changes: 26 additions & 0 deletions packages/browserstack-service/tests/launcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,32 @@ describe('onPrepare', () => {
expect(service.browserstackLocal).toBeUndefined()
})

it('does not start a service-side Percy when the CLI is running', async () => {
const isRunningSpy = vi.spyOn(BrowserstackCLI.getInstance(), 'isRunning').mockReturnValue(true)
const service = new BrowserstackLauncher({ testObservability: false, percy: true } as any, caps, config)
const setupPercySpy = vi.spyOn(service, 'setupPercy').mockResolvedValue(undefined)
try {
await service.onPrepare(config, caps)
} finally {
isRunningSpy.mockRestore()
}

expect(setupPercySpy).not.toHaveBeenCalled()
})

it('starts a service-side Percy when the CLI is not running', async () => {
const isRunningSpy = vi.spyOn(BrowserstackCLI.getInstance(), 'isRunning').mockReturnValue(false)
const service = new BrowserstackLauncher({ testObservability: false, percy: true } as any, caps, config)
const setupPercySpy = vi.spyOn(service, 'setupPercy').mockResolvedValue(undefined)
try {
await service.onPrepare(config, caps)
} finally {
isRunningSpy.mockRestore()
}

expect(setupPercySpy).toHaveBeenCalledTimes(1)
})

it('should add the "app" property to a multiremote capability if no "bstack:options"', async () => {
const options: BrowserstackConfig = { app: 'bs://<app-id>' }
const service = new BrowserstackLauncher(options as any, caps, config)
Expand Down
Loading