Front-end testing cleanup and improvements #7059
Conversation
@@ -121,7 +121,7 @@ module.exports = { | |||
// setupFiles: [], | |||
|
|||
// The path to a module that runs some code to configure or set up the testing framework before each test | |||
// setupTestFrameworkScriptFile: null, |
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.
From the Jest docs:
Note: setupTestFrameworkScriptFile is deprecated in favor of setupFilesAfterEnv.
@@ -55,7 +55,9 @@ export default function Article({ document }: DocumentProps) { | |||
// This is a one-time effect we need to call the first time an article | |||
// is rendered, to ensure that interactive examples resize themselves | |||
// if the browser width changes. | |||
useEffect(InteractiveExamples.makeResponsive, []); | |||
useEffect(() => { |
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 to fix an eslint error from react-hooks
, it said to make this an inline function.
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 this works it works for me.
} | ||
}, [props.initialQuery]); | ||
}, [initialQuery]); |
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.
Another eslint error fix-- props
will change when any props change (in this case there's only one prop right now so it doesn't really matter) so the fix is to destructure props and refer to the specific props inside useEffect
.
Changes:
eslint-plugin-testing-library
(thanks @peterbe for sharing this article!)jest-dom
before test files - I think we use it enough that it makes sense to always have it available.To test:
Run
jest