Skip to content

Commit 01157d7

Browse files
committed
02/05: add solution, fix expect.element
1 parent 85d1e6d commit 01157d7

File tree

30 files changed

+278
-12
lines changed

30 files changed

+278
-12
lines changed

exercises/01.sunsetting-jsdom/01.problem.break-jsdom/postcss.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
export default {
22
plugins: {
33
tailwindcss: {},
44
autoprefixer: {},

exercises/01.sunsetting-jsdom/01.solution.break-jsdom/postcss.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
export default {
22
plugins: {
33
tailwindcss: {},
44
autoprefixer: {},

exercises/02.vitest-browser-mode/01.solution.installation-and-setup/postcss.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
export default {
22
plugins: {
33
tailwindcss: {},
44
autoprefixer: {},

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
1. Install `vitest-browser-react` to render React components in the browser.
55
1. Use `render` from `vitest-browser-react` to render the component now.
66
1. Use `page` from `@vitest/browser/context` to select elements on the page for interactions and assertions.
7+
1. Since `page.getBy*` now returns ` Locator` object, adjust `expect` to be `expect.element(locator)` and await its assertions as they are async now.

exercises/02.vitest-browser-mode/02.solution.migrate-the-test/postcss.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
export default {
22
plugins: {
33
tailwindcss: {},
44
autoprefixer: {},

exercises/02.vitest-browser-mode/02.solution.migrate-the-test/src/file-preview.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ import { FilePreview } from './file-preview.tsx'
66
it('displays the preview card', async () => {
77
render(<FilePreview file={new File(['hello world'], 'file.txt')} />)
88

9-
expect(page.getByText('file.txt')).toBeTruthy()
10-
expect(page.getByText('hello world')).toBeTruthy()
9+
await expect.element(page.getByText('file.txt')).toBeTruthy()
10+
await expect.element(page.getByText('hello world')).toBeTruthy()
1111
})

exercises/02.vitest-browser-mode/03.solution.use-playwright/postcss.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
export default {
22
plugins: {
33
tailwindcss: {},
44
autoprefixer: {},

exercises/02.vitest-browser-mode/03.solution.use-playwright/src/file-preview.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ import { FilePreview } from './file-preview.tsx'
66
it('displays the preview card', async () => {
77
render(<FilePreview file={new File(['hello world'], 'file.txt')} />)
88

9-
expect(page.getByText('file.txt')).toBeTruthy()
10-
expect(page.getByText('hello world')).toBeTruthy()
9+
await expect.element(page.getByText('file.txt')).toBeTruthy()
10+
await expect.element(page.getByText('hello world')).toBeTruthy()
1111
})

exercises/02.vitest-browser-mode/04.solution.use-dom-assertions/postcss.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
export default {
22
plugins: {
33
tailwindcss: {},
44
autoprefixer: {},

exercises/02.vitest-browser-mode/04.solution.use-dom-assertions/src/file-preview.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ import { FilePreview } from './file-preview.tsx'
66
it('displays the preview card', async () => {
77
render(<FilePreview file={new File(['hello world'], 'file.txt')} />)
88

9-
expect(page.getByText('file.txt')).toBeVisible()
10-
expect(page.getByText('hello world')).toBeVisible()
9+
await expect.element(page.getByText('file.txt')).toBeVisible()
10+
await expect.element(page.getByText('hello world')).toBeVisible()
1111
})

0 commit comments

Comments
 (0)