Skip to content

Commit f0c0de1

Browse files
committed
add video embeds
1 parent a45de51 commit f0c0de1

File tree

38 files changed

+78
-2
lines changed

38 files changed

+78
-2
lines changed

exercises/01.sunsetting-jsdom/01.problem.break-jsdom/README.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Break JSDOM
22

3+
<EpicVideo url="https://www.epicweb.dev/workshops/react-component-testing-with-vitest/sunsetting-jsdom/break-jsdom" />
4+
35
Before we talk about in-browser component testing, let's start with something familiar.
46

57
In this exercise, you have a simple React application that previews the files you upload from your computer. To do that, it has a `type="file"` input and reads the content of the chosen file to display it for the user.

exercises/01.sunsetting-jsdom/01.solution.break-jsdom/README.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Break JSDOM
22

3+
<EpicVideo url="https://www.epicweb.dev/workshops/react-component-testing-with-vitest/sunsetting-jsdom/break-jsdom/solution" />
4+
35
I start with rendering the `<FilePreview />` component in my test:
46

57
```tsx add=1,5
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# Sunsetting JSDOM
22

3+
<EpicVideo url="https://www.epicweb.dev/workshops/react-component-testing-with-vitest/sunsetting-jsdom/recap-of-sunsetting-jsdom" />
4+
35
Great job! 🎉 Have some rest and let's continue.

exercises/01.sunsetting-jsdom/README.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Sunsetting JSDOM
22

3+
<EpicVideo url="https://www.epicweb.dev/workshops/react-component-testing-with-vitest/sunsetting-jsdom/intro-to-sunsetting-jsdom" />
4+
35
You came to this workshop to learn a new way of testing your UI components, but before we get anywhere near to that, I want you to understand _why_ this change is needed. The last thing I want you to do is refactor your tests just because I told you to. I want _you_ to understand the flawed reality of browser-like environments by experiencing how they let you down firsthand. By the end of this tiny exercise you won't have any wish to use those environments anymore.
46

57
But what are browser-like environments, to start with?

exercises/02.vitest-browser-mode/01.problem.installation-and-setup/README.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Installation and setup
22

3+
<EpicVideo url="https://www.epicweb.dev/workshops/react-component-testing-with-vitest/vitest-browser-mode/installation-and-setup" />
4+
35
It's time to take the first step forward Vitest Browser Mode! In this one, you and I are going to install all the necessary dependencies so we can start testing our components in the actual browser.
46

57
## Install dependencies

exercises/02.vitest-browser-mode/01.solution.installation-and-setup/README.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Installation and setup
22

3+
<EpicVideo url="https://www.epicweb.dev/workshops/react-component-testing-with-vitest/vitest-browser-mode/installation-and-setup/solution" />
4+
35
That's it! :tada: You have everything you need to finally start testing your browser code in the browser.
46

57
If you try running tests right now, you will get an error:

exercises/02.vitest-browser-mode/02.problem.migrate-the-test/README.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Migrate the test
22

3+
<EpicVideo url="https://www.epicweb.dev/workshops/react-component-testing-with-vitest/vitest-browser-mode/migrate-the-test" />
4+
35
Since you are migrating your test from running in Node.js to running in the browser, some changes have to be made to your test suites for that to work. Luckily, these changes aren't dramatic, and mostly involve importing the same things from different packages.
46

57
> 🦉 The biggest change when adopting Vitest Browser Mode is that it splits the rendering and the UI selection/interaction between two separate packages: `@vitest/browser` and a framework-specific renderer package, like `vitest-browser-react`.

exercises/02.vitest-browser-mode/02.solution.migrate-the-test/README.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Migrate the test
22

3+
<EpicVideo url="https://www.epicweb.dev/workshops/react-component-testing-with-vitest/vitest-browser-mode/migrate-the-test/solution" />
4+
35
While component tests in Vitest Browser Mode are extremely similar to those you used to write in JSDOM, there are a couple of key differences around component rendering, selecting elements on the page, and writing assertions.
46

57
## Rendering

exercises/02.vitest-browser-mode/03.problem.playwright/README.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Playwright
22

3+
<EpicVideo url="https://www.epicweb.dev/workshops/react-component-testing-with-vitest/vitest-browser-mode/playwright" />
4+
35
The first thing that we can improve is the _browser provider_ used to run our tests. By default, Vitest uses the `preview` provider, which is a great way to get started with the Browser Mode quickly but is not something you would want to use in your application.
46

57
The default `preview` provider has a few intentional limitations:

exercises/02.vitest-browser-mode/03.solution.playwright/README.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Playwright
22

3+
<EpicVideo url="https://www.epicweb.dev/workshops/react-component-testing-with-vitest/vitest-browser-mode/playwright/solution" />
4+
35
Let's start by installing `playwright`:
46

57
```sh nonumber

0 commit comments

Comments
 (0)