-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(e2e): add e2e cases for MDX (#1552)
- Loading branch information
1 parent
16d939f
commit e6820a5
Showing
16 changed files
with
131 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { expect } from '@playwright/test'; | ||
import { build, gotoPage, rspackOnlyTest } from '@e2e/helper'; | ||
|
||
rspackOnlyTest('should render MDX with Preact correctly', async ({ page }) => { | ||
const rsbuild = await build({ | ||
cwd: __dirname, | ||
runServer: true, | ||
}); | ||
|
||
await gotoPage(page, rsbuild); | ||
expect(await page.innerHTML('h1')).toEqual('Hello, world!'); | ||
expect(await page.innerHTML('#test')).toEqual( | ||
'<p style="padding: 1rem;">Test</p>', | ||
); | ||
|
||
await rsbuild.close(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { defineConfig } from '@rsbuild/core'; | ||
import { pluginPreact } from '@rsbuild/plugin-preact'; | ||
import { pluginMdx } from '@rsbuild/plugin-mdx'; | ||
|
||
export default defineConfig({ | ||
plugins: [ | ||
pluginPreact(), | ||
pluginMdx({ | ||
mdxLoaderOptions: { | ||
jsxImportSource: 'preact', | ||
}, | ||
}), | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Hello, world! | ||
|
||
Below is an example of markdown in JSX. | ||
|
||
<div id="test"> | ||
<p style={{ padding: '1rem' }}>Test</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { render } from 'preact'; | ||
import App from './app'; | ||
|
||
render(<App />, document.getElementById('root')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { expect } from '@playwright/test'; | ||
import { build, gotoPage, rspackOnlyTest } from '@e2e/helper'; | ||
|
||
rspackOnlyTest('should render MDX with React correctly', async ({ page }) => { | ||
const rsbuild = await build({ | ||
cwd: __dirname, | ||
runServer: true, | ||
}); | ||
|
||
await gotoPage(page, rsbuild); | ||
expect(await page.innerHTML('h1')).toEqual('Hello, world!'); | ||
expect(await page.innerHTML('#test')).toEqual( | ||
'<p style="padding: 1rem;">Test</p>', | ||
); | ||
|
||
await rsbuild.close(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { defineConfig } from '@rsbuild/core'; | ||
import { pluginReact } from '@rsbuild/plugin-react'; | ||
import { pluginMdx } from '@rsbuild/plugin-mdx'; | ||
|
||
export default defineConfig({ | ||
plugins: [pluginReact(), pluginMdx()], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Hello, world! | ||
|
||
Below is an example of markdown in JSX. | ||
|
||
<div id="test"> | ||
<p style={{ padding: '1rem' }}>Test</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom/client'; | ||
import App from './app'; | ||
|
||
const root = ReactDOM.createRoot(document.getElementById('root')); | ||
root.render(<App />); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { expect } from '@playwright/test'; | ||
import { build, gotoPage, rspackOnlyTest } from '@e2e/helper'; | ||
|
||
rspackOnlyTest('should render MDX with Vue correctly', async ({ page }) => { | ||
const rsbuild = await build({ | ||
cwd: __dirname, | ||
runServer: true, | ||
}); | ||
|
||
await gotoPage(page, rsbuild); | ||
expect(await page.innerHTML('h1')).toEqual('Hello, world!'); | ||
expect(await page.innerHTML('#test')).toEqual( | ||
'<p style="padding: 1rem;">Test</p>', | ||
); | ||
|
||
await rsbuild.close(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { defineConfig } from '@rsbuild/core'; | ||
import { pluginVue } from '@rsbuild/plugin-vue'; | ||
import { pluginMdx } from '@rsbuild/plugin-mdx'; | ||
|
||
export default defineConfig({ | ||
plugins: [ | ||
pluginVue(), | ||
pluginMdx({ | ||
mdxLoaderOptions: { | ||
jsxImportSource: 'vue', | ||
}, | ||
}), | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Hello, world! | ||
|
||
Below is an example of markdown in JSX. | ||
|
||
<div id="test"> | ||
<p style={{ padding: '1rem' }}>Test</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { createApp } from 'vue'; | ||
import App from './app'; | ||
|
||
createApp(App).mount('#root'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.