-
Notifications
You must be signed in to change notification settings - Fork 28
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
Issue #733 dont use index for keys testcases #823
base: staging
Are you sure you want to change the base?
Conversation
Great start! Leaving a few comments for changes |
@@ -0,0 +1,2 @@ | |||
{ |
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.
Might be a good idea to add this to the .gitignore
, that way git won't accidently pick up config files.
@@ -204,7 +204,7 @@ | |||
"transformIgnorePatterns": [ | |||
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs|cjs|ts|tsx)$", | |||
"^.+\\.module\\.(css|sass|scss)$", | |||
"node_modules\/(?!axios)" | |||
"node_modules/(?!axios)" |
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.
nice catch!
|
||
const test_uuid = '9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d'; | ||
|
||
jest.mock('uuid', () => { |
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.
really good use of mock for a randomized ID from an external library. Once you merge this PR, you should definitely add this as an example test file in the Testing wiki
// Invariant Violation: Could not find "store" | ||
render(<ChapterInfo {...baseProps} />); | ||
|
||
const contents = getAllByTestId('content'); |
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.
Looks like jest isn't able to work without a redux state, which is unfortunately wrapped by DvaJS. This might need some research on how to mock but we'll figure this out later.
// Invariant Violation: Could not find "store" | ||
render(<SubChapterItem {...baseProps} />); | ||
|
||
const contents = getAllByTestId('content'); |
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 probably needs to be screen.getAllByTestId
to fix the error
|
||
|
||
describe('ChapterContent Component', () => { | ||
const mockDispatch = jest.fn(); |
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.
If we aren't using these variables anywhere else, might be simpler to just have jest.fn()
in props directly similar to your other test files, though this works fine too since the readability is quite clear in both cases.
@mumbler6 doing the test cases looks like it's getting quite complicated since it's dealing with redux. I think we can put these on the back burner for now to if you want spend more time focusing on something else. Feel free to fix anything from the comments and merge the other PR before wrapping up and starting on another issue. I can try taking a crack at this in a bit too, I haven't mocked anything |
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.
LGTM. Note in INoteChapter.test.js (line 26)- there was a build failure-
'getAllByTestId' is not defined
contents.forEach((content) => {
expect(content).toHaveAttribute('key', `ch-content-chapter-id-1-${test_uuid}}`);
});```
You will also want to rebase or merge in latest from staging |
Merging recent updates into branch.
My bad, Harsh left a comment about it before. Hopefully this'll fix it. Though it looks like the test case errors are also part of the build failure. |
Attempted to write test cases that supplement issue #733, but have errors from importing and from redux while rendering components.