-
-
Notifications
You must be signed in to change notification settings - Fork 191
test(react-swc): simplify ts-lib test #548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a15ad1b
test: simplify ts-lib test
hi-ogawa 91d6144
chore: cleanup
hi-ogawa d0efa9b
chore: cleanup
hi-ogawa 002d306
chore: more cleanup
hi-ogawa b5ea72a
chore: lint
hi-ogawa be819c8
Merge branch 'main' into 07-08-test_simplify_ts-lib_test
hi-ogawa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 contains hidden or 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
20 changes: 9 additions & 11 deletions
20
packages/plugin-react-swc/playground/ts-lib/__tests__/ts-lib.spec.ts
This file contains hidden or 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 |
|---|---|---|
| @@ -1,24 +1,22 @@ | ||
| import { expect, test } from '@playwright/test' | ||
| import { type Page, expect, test } from '@playwright/test' | ||
| import { setupBuildAndPreview, setupDevServer } from '../../utils.ts' | ||
|
|
||
| test('TS lib build', async ({ page }) => { | ||
| const { testUrl, server } = await setupBuildAndPreview('ts-lib') | ||
| await page.goto(testUrl) | ||
| await expect(page.locator('main')).toHaveText('Home page') | ||
|
|
||
| await page.locator('a', { hasText: 'About' }).click() | ||
| await expect(page.locator('main')).toHaveText('About page') | ||
|
|
||
| await testNonJs(page) | ||
| await server.httpServer.close() | ||
| }) | ||
|
|
||
| test('TS lib dev', async ({ page }) => { | ||
| const { testUrl, server } = await setupDevServer('ts-lib') | ||
| await page.goto(testUrl) | ||
| await expect(page.locator('main')).toHaveText('Home page') | ||
|
|
||
| await page.locator('a', { hasText: 'About' }).click() | ||
| await expect(page.locator('main')).toHaveText('About page') | ||
|
|
||
| await testNonJs(page) | ||
| await server.close() | ||
| }) | ||
|
|
||
| async function testNonJs(page: Page) { | ||
| await expect(page.getByTestId('test-non-js')).toHaveText('test-non-js: 0') | ||
| await page.getByTestId('test-non-js').click() | ||
| await expect(page.getByTestId('test-non-js')).toHaveText('test-non-js: 1') | ||
| } |
This file contains hidden or 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 contains hidden or 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,11 @@ | ||
| import TestNonJs from '@vitejs/test-dep-non-js' | ||
|
|
||
| export default function App() { | ||
| return ( | ||
| <section style={{ margin: 24 }}> | ||
| <main> | ||
| <TestNonJs /> | ||
| </main> | ||
| </section> | ||
| ) | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| import { StrictMode } from 'react' | ||
| import { createRoot } from 'react-dom/client' | ||
| import { Routes } from 'generouted/react-router' | ||
| import App from './app' | ||
|
|
||
| createRoot(document.getElementById('root')!).render( | ||
| <StrictMode> | ||
| <Routes /> | ||
| <App /> | ||
| </StrictMode>, | ||
| ) |
3 changes: 0 additions & 3 deletions
3
packages/plugin-react-swc/playground/ts-lib/src/pages/404.tsx
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
packages/plugin-react-swc/playground/ts-lib/src/pages/_app.tsx
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
packages/plugin-react-swc/playground/ts-lib/src/pages/about.tsx
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
packages/plugin-react-swc/playground/ts-lib/src/pages/index.tsx
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
packages/plugin-react-swc/playground/ts-lib/test-dep/non-js/index.tsx
This file contains hidden or 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,10 @@ | ||
| import React from 'react' | ||
|
|
||
| export default function TestNonJs() { | ||
| const [count, setCount] = React.useState(0) | ||
| return ( | ||
| <button data-testid="test-non-js" onClick={() => setCount(count + 1)}> | ||
| test-non-js: {count} | ||
| </button> | ||
| ) | ||
| } |
9 changes: 9 additions & 0 deletions
9
packages/plugin-react-swc/playground/ts-lib/test-dep/non-js/package.json
This file contains hidden or 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,9 @@ | ||
| { | ||
| "name": "@vitejs/test-dep-non-js", | ||
| "private": true, | ||
| "type": "module", | ||
| "exports": "./index.tsx", | ||
| "peerDependencies": { | ||
| "react": "*" | ||
| } | ||
| } |
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I don't think this as the same behaviour as being in node_modules because node_modules is not in the resolved path
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.
file:./doesn't create a symlink, so the scenario should be same. I also confirmed manually adding backif (id.includes("node_modules")) return;indeed broke the tests.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.
Oh ok thanks for testing!