-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: Moves the test utils generation script to this repo #77
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #77 +/- ##
==========================================
+ Coverage 95.75% 95.92% +0.16%
==========================================
Files 6 9 +3
Lines 283 319 +36
Branches 65 68 +3
==========================================
+ Hits 271 306 +35
- Misses 12 13 +1 ☔ View full report in Codecov by Sentry. |
55ccd6b
to
98b36f6
Compare
98b36f6
to
8f3e6af
Compare
*/ | ||
export function getComponentMetadata(componentName: string) { | ||
return ${buildComponentsMetadataMap(components)}[componentName]; | ||
} |
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.
The above function is the only one that is new. Everything else is just transferred from other repos.
7d6968b
to
aae87eb
Compare
@@ -27,13 +27,15 @@ | |||
"css-selector-tokenizer": "^0.8.0", | |||
"css.escape": "^1.5.1", | |||
"glob": "^7.2.0", | |||
"lodash": "^4.17.21", |
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.
We use lodash for casing conversion.
generateTestUtils({ | ||
components: mockComponents, | ||
testUtilsPath, | ||
}); |
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.
Since generateTestUtils
is called inside the build phase (npm build
) rather than the test runner (npm test
), test runner doesn't include this inside the test coverage report.
For this reason we had to add additional unit tests to the individual functions to keep the test coverage high.
@@ -0,0 +1,53 @@ | |||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
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.
This is the second test file that we had to write to keep the test coverage high.
@@ -0,0 +1,74 @@ | |||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
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.
This is one of the unit tests that we had to write to keep the test coverage high.
|
||
const testUtilsFilePartialContent = 'ElementWrapper.prototype.findAlert'; | ||
|
||
expect(writeFileSync).toHaveBeenCalledWith( |
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.
I'm curious how does it work? I believe the mocked version of this function should be used instead
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.
Since mock calls (vi.mock
) are hoisted to the top of the execution context, every function that is imported from that path is will be mocked. That's actually why this assertion is passing, otherwise we would get something like:
TypeError: [Function] is not a spy or a call to a spy!
Description of changes:
Centralizes the logic repeated in these four files:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Issue #, if available:
Will be followed by PRs:
Related API Proposal: Test utils component finder generator