File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ Twitter
5050
5151Each component will at some point require at least one test to check it renders correctly. Each component in
5252` mdx-embed/src/components/ ` is wrapped in what we call the ** GeneralObserver** This component is responsible for
53- ensuring the 3rd part embed script isn't invoked until the component has entered the viewport. This is particularly
53+ ensuring the 3rd party embed script isn't invoked until the component has entered the viewport. This is particularly
5454important for Lighthouse scores and page load speeds. If a blog post page for example has 10 or 15 embed codes, Twitter,
5555CodePend, YouTube etc on the page we don't want to load all that 3rd party JavaScript until the reader has scrolled down
5656to where the component is used. When it scrolls in to view ** GeneralObserver** which is an
@@ -61,9 +61,9 @@ This presents an issue when we come to test the components because we need to fa
6161which allows the children of ** GeneralObserver** to render.
6262
6363To _ mock_ this is a test we've globally exposed a method called ` triggerGeneralObserver() ` and since we're using Testing
64- Library this state change must be wrapped in an ` act ` .
64+ Library this state change must be wrapped in an [ act] ( https://testing-library.com/docs/react-testing-library/api#act ) .
6565
66- With that said we require each ` test(() => {}) ` to contain an ` act() ` and a call to ` triggerGeneralObserver() `
66+ With that said we require each ` test(() => {}) ` to contain an ` act(() => {} ) ` and a call to ` triggerGeneralObserver() `
6767
6868That looks like something like this: the ` (window as any) ` is a TypeScript thing... Paul is working on it.
6969
You can’t perform that action at this time.
0 commit comments