-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
export platform specific objects through proxy #374
Merged
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
fdc37b0
export platform specific objects throw proxy
trofima d9ac3f1
Merge branch 'master' into export-platform-related-objects
trofima a5051c1
Fixed spread errors. Fixed existing tests. Moved out deviceConfig gen…
trofima 3467079
exportWrapper tests, Detox test fixed.
trofima 26dcd9f
platform tests
trofima e497d74
minor refactor
trofima f756c5a
Merge branch 'master' into export-platform-related-objects
trofima 6144ea9
Merge branch 'master' into export-platform-related-objects
trofima 131fd02
Merge branch 'master' into export-platform-related-objects
trofima e61d411
trying to make it work
trofima e9f768c
fixed default params
trofima 4d01084
comments cleaned
trofima da315b4
improved proxying of the 'by' and 'device' objects
trofima 8325aff
Detox default params extension fixed, tests for exportWrapper added
trofima c091a9c
- Added support for custom specs with cli tool
rotemmiz 6c987c6
Merge branch 'master' into export-platform-related-objects
trofima 85f45c0
exportWrapper tests, mock fixed.
trofima 055fb2c
Merge branch 'master' into export-platform-related-objects
rotemmiz 2e4132d
fixed broken command
rotemmiz 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
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,28 +1,56 @@ | ||
const iosExports = require('./ios/expect'); | ||
const androidExports = require('./android/expect'); | ||
const exportWrapper = require('./exportWrapper'); | ||
const platform = require('./platform'); | ||
jest.mock('./ios/expect'); | ||
jest.mock('./android/expect'); | ||
const iosExports = require('./ios/expect'); | ||
const androidExports = require('./android/expect'); | ||
|
||
describe('exportWrapper', () => { | ||
const mockDevice = {}; | ||
const mockDevice = {method: jest.fn()}; | ||
|
||
it(`proxies ios specific objects`, async () => { | ||
const arg1 = 1; | ||
const arg2 = 'test'; | ||
|
||
it(`exports ios specific objects`, async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These tests are not being passed locally with wallaby, I think its related to the fact that they are not being reset correctly |
||
platform.set('ios.none', mockDevice); | ||
iosExports.by.method = jest.fn(); | ||
|
||
exportWrapper.device.method(arg1, arg2); | ||
expect(mockDevice.method).toHaveBeenCalledWith(arg1, arg2); | ||
|
||
exportWrapper.expect(arg1, arg2); | ||
expect(iosExports.expect).toHaveBeenCalledWith(arg1, arg2); | ||
|
||
expect(exportWrapper.device).toBe(mockDevice); | ||
expect(exportWrapper.expect).toBe(iosExports.expect); | ||
expect(exportWrapper.element).toBe(iosExports.element); | ||
expect(exportWrapper.waitFor).toBe(iosExports.waitFor); | ||
expect(exportWrapper.by).toBe(iosExports.by); | ||
exportWrapper.element(arg1, arg2); | ||
expect(iosExports.element).toHaveBeenCalledWith(arg1, arg2); | ||
|
||
exportWrapper.waitFor(arg1, arg2); | ||
expect(iosExports.waitFor).toHaveBeenCalledWith(arg1, arg2); | ||
|
||
exportWrapper.by.method(arg1, arg2); | ||
expect(iosExports.by.method).toHaveBeenCalledWith(arg1, arg2); | ||
}); | ||
|
||
it(`exports android specific objects`, async () => { | ||
it(`proxies android specific objects`, async () => { | ||
const arg1 = 1; | ||
const arg2 = 'test'; | ||
|
||
platform.set('android.attached', mockDevice); | ||
androidExports.by.method = jest.fn(); | ||
|
||
exportWrapper.device.method(arg1, arg2); | ||
expect(mockDevice.method).toHaveBeenCalledWith(arg1, arg2); | ||
|
||
exportWrapper.expect(arg1, arg2); | ||
expect(androidExports.expect).toHaveBeenCalledWith(arg1, arg2); | ||
|
||
exportWrapper.element(arg1, arg2); | ||
expect(androidExports.element).toHaveBeenCalledWith(arg1, arg2); | ||
|
||
exportWrapper.waitFor(arg1, arg2); | ||
expect(androidExports.waitFor).toHaveBeenCalledWith(arg1, arg2); | ||
|
||
expect(exportWrapper.device).toBe(mockDevice); | ||
expect(exportWrapper.expect).toBe(androidExports.expect); | ||
expect(exportWrapper.element).toBe(androidExports.element); | ||
expect(exportWrapper.waitFor).toBe(androidExports.waitFor); | ||
expect(exportWrapper.by).toBe(androidExports.by); | ||
exportWrapper.by.method(arg1, arg2); | ||
expect(androidExports.by.method).toHaveBeenCalledWith(arg1, arg2); | ||
}); | ||
}); |
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.
make sure you reset the mocks, instead of doing it statically, require and mock everything in
beforeEach
inside the suite (in thedescribe
)