-
Notifications
You must be signed in to change notification settings - Fork 448
fix: Add babel configuration for Playwright to handle TypeScript declare fields #5515
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
Closed
Closed
Changes from 22 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
d8ff3df
reset branch
snomiao c5c54df
fix: remove unused dependencies and files flagged by knip
snomiao c66843e
fix: resolve knip issues - remove unused babel-plugin-module-resolver…
snomiao c4cb359
istall babel plugins
snomiao c3e2588
fix: resolve collect-i18n babel transformation issues
snomiao 20e1cb0
fix: resolve TypeScript errors in collect-i18n-general.ts
snomiao 66706f8
fix: remove scripts/collect-i18n-*.ts from tsconfig includes
snomiao 14bc5ad
fix: revert unnecessary package.json version changes
snomiao 1b87f29
fix: update pnpm-lock.yaml to match package.json
snomiao 81314b6
Update locales [skip ci]
invalid-email-address 7002a17
fix: add saveImmediately option to i18n configuration
snomiao 1741677
Update locales [skip ci]
invalid-email-address 7ec9f0b
Merge branch 'main' into sno-fix-playwright-babel-config
snomiao 247937f
Update locales [skip ci]
invalid-email-address b98458d
fix: remove unused imports and streamline node definitions collection
snomiao 23ba2fe
Merge branch 'sno-fix-playwright-babel-config' of github.com:Comfy-Or…
snomiao 12a130b
Merge branch 'main' into sno-fix-playwright-babel-config
snomiao c785ccf
Update locales [skip ci]
invalid-email-address 916170e
Update locales [skip ci]
invalid-email-address 89465de
Revert "Update locales [skip ci]"
snomiao 8560646
chore(babel-plugin-stub-vue-imports): remove unused Babel plugin for …
snomiao 82c6f02
Merge branch 'main' into sno-fix-playwright-babel-config
snomiao 8fdee1b
Merge branch 'main' into sno-fix-playwright-babel-config
snomiao 7abda29
Update locales [skip ci]
invalid-email-address 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
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
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,12 +1,57 @@ | ||
| import { defineConfig } from '@playwright/test' | ||
| import path from 'path' | ||
| import { fileURLToPath } from 'url' | ||
|
|
||
| export default defineConfig({ | ||
| const __dirname = path.dirname(fileURLToPath(import.meta.url)) | ||
|
|
||
| const config: any = defineConfig({ | ||
| testDir: './scripts', | ||
| use: { | ||
| baseURL: 'http://localhost:5173', | ||
| headless: true | ||
| baseURL: 'http://localhost:5173' | ||
| }, | ||
| reporter: 'list', | ||
| timeout: 60000, | ||
| testMatch: /collect-i18n-.*\.ts/ | ||
| workers: 1, // Run tests serially to avoid duplicate user creation | ||
| testMatch: /collect-i18n-.*\.ts/, | ||
| // Start dev server before running tests | ||
| webServer: { | ||
| command: 'pnpm dev', | ||
| url: 'http://localhost:5173', | ||
| reuseExistingServer: true, | ||
| timeout: 60000 | ||
| } | ||
| }) | ||
|
|
||
| // Configure babel plugins for TypeScript with declare fields and module resolution | ||
| config['@playwright/test'] = { | ||
| babelPlugins: [ | ||
| // Module resolver to handle @ alias | ||
| [ | ||
| 'babel-plugin-module-resolver', | ||
| { | ||
| root: ['./'], | ||
| alias: { | ||
| '@': './src' | ||
| } | ||
| } | ||
| ], | ||
| // TypeScript transformation with declare field support | ||
| [ | ||
| '@babel/plugin-transform-typescript', | ||
| { | ||
| allowDeclareFields: true, | ||
| onlyRemoveTypeImports: true | ||
| } | ||
| ], | ||
| // Inject browser globals AFTER TypeScript transformation | ||
| [ | ||
| path.join(__dirname, 'scripts/babel-plugin-inject-globals.cjs'), | ||
| { | ||
| filenamePattern: 'collect-i18n-', | ||
| setupFile: './setup-browser-globals.mjs' | ||
| } | ||
| ] | ||
| ] | ||
| } | ||
|
|
||
| export default config |
Large diffs are not rendered by default.
Oops, something went wrong.
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,30 @@ | ||
| module.exports = function(babel) { | ||
| const { types: t } = babel; | ||
|
|
||
| return { | ||
| visitor: { | ||
| Program(path, state) { | ||
| // Get options from plugin configuration | ||
| const opts = state.opts || {}; | ||
| const filenamePattern = opts.filenamePattern || DIE('filenamePattern option is required'); | ||
| const setupFile = opts.setupFile || DIE('setupFile option is required'); | ||
|
|
||
| // Only inject the setup for matching test files | ||
| if (state.filename?.match(filenamePattern)) { | ||
| // Create an import statement for the setup file | ||
| const importDeclaration = t.importDeclaration( | ||
| [], | ||
| t.stringLiteral(setupFile) | ||
| ); | ||
|
|
||
| // Insert the import at the beginning of the file | ||
| path.node.body.unshift(importDeclaration); | ||
| } | ||
| } | ||
| } | ||
| }; | ||
| }; | ||
|
|
||
| function DIE(msg) { | ||
| throw new Error(msg); | ||
| } |
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
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.
this is for testing, can be resotred after/before merge this pr
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.
probably before right?