-
Notifications
You must be signed in to change notification settings - Fork 18
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
fix: pass browserInstance through to execute
#329
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
16e8188
fix: pass browserInstance through to execute
goosewobbler cc45b9b
test: update single instance MR E2E
goosewobbler 0ba4524
chore: update lockfiles
goosewobbler a145b30
test: update execute units
goosewobbler 30d9410
chore: exclude symlinked cjs files from coverage
goosewobbler 262d192
chore: update unit coverage
goosewobbler ec2f76c
Merge branch 'main' into sm/mr-execute-fix
goosewobbler f3340c9
Merge branch 'main' into sm/mr-execute-fix
goosewobbler 6751ee1
fix: merge issues
goosewobbler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,41 @@ | ||
import { vi, describe, beforeEach, it, expect } from 'vitest'; | ||
|
||
import { execute } from '../../src/commands/execute'; | ||
import ElectronWorkerService from '../../src'; | ||
|
||
describe('execute', () => { | ||
let workerService; | ||
beforeEach(async () => { | ||
globalThis.browser = { | ||
execute: vi.fn(), | ||
} as unknown as WebdriverIO.Browser; | ||
workerService = new ElectronWorkerService({}); | ||
workerService.browser = globalThis.browser; | ||
}); | ||
|
||
it('should throw an error when called with a parameter of the wrong type', async () => { | ||
await expect(() => execute.call(workerService, {})).rejects.toThrowError( | ||
it('should throw an error when called with a script argument of the wrong type', async () => { | ||
await expect(() => execute(globalThis.browser, {} as string)).rejects.toThrowError( | ||
new Error('Expecting script to be type of "string" or "function"'), | ||
); | ||
}); | ||
|
||
it('should throw an error when called without a parameter', async () => { | ||
await expect(() => execute.call(workerService)).rejects.toThrowError( | ||
it('should throw an error when called without a script argument', async () => { | ||
// @ts-expect-error no script argument | ||
await expect(() => execute(globalThis.browser)).rejects.toThrowError( | ||
new Error('Expecting script to be type of "string" or "function"'), | ||
); | ||
}); | ||
|
||
it('should throw an error when the browser is not initialised', async () => { | ||
workerService.browser = undefined; | ||
await expect(() => execute.call(workerService, 'return 1 + 2 + 3')).rejects.toThrowError( | ||
// @ts-expect-error undefined browser argument | ||
await expect(() => execute(undefined, 'return 1 + 2 + 3')).rejects.toThrowError( | ||
new Error('WDIO browser is not yet initialised'), | ||
); | ||
}); | ||
|
||
it('should execute a stringified function', async () => { | ||
await execute.call(workerService, 'return 1 + 2 + 3'); | ||
await execute(globalThis.browser, 'return 1 + 2 + 3'); | ||
expect(globalThis.browser.execute).toHaveBeenCalledWith('return 1 + 2 + 3'); | ||
}); | ||
|
||
it('should execute a function', async () => { | ||
await execute.call(workerService, () => 1 + 2 + 3); | ||
await execute(globalThis.browser, () => 1 + 2 + 3); | ||
expect(globalThis.browser.execute).toHaveBeenCalledWith(expect.any(Function), '() => 1 + 2 + 3'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
and then do:
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.
Tried these two - the instance test fails, producing an array of values again