diff --git a/.github/workflows/test.yml b/.github/workflows/e2e-test.yml similarity index 79% rename from .github/workflows/test.yml rename to .github/workflows/e2e-test.yml index e8e5689..47df6b8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/e2e-test.yml @@ -18,7 +18,7 @@ jobs: container: node:20 strategy: matrix: - project: [vite-vite, vite-webpack-rspack] + project: [nuxt-vite, rust-vite, vite-vite, multi-example] steps: - name: Checkout uses: actions/checkout@v4 @@ -42,6 +42,12 @@ jobs: if [ "${{ matrix.project }}" = "vite-vite" ]; then nohup pnpm run dev-vv & pnpm exec wait-on http://localhost:5175; + elif [ "${{ matrix.project }}" = "nuxt-vite" ]; then + nohup pnpm run dev-nv & + pnpm exec wait-on http://localhost:3001; + elif [ "${{ matrix.project }}" = "rust-vite" ]; then + nohup pnpm run dev-rv & + pnpm exec wait-on http://localhost:5172; else nohup pnpm run multi-example & pnpm exec wait-on http://localhost:5173; diff --git a/.gitignore b/.gitignore index ffd9274..425926d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,6 @@ dist .idea .__mf__win lib -**/.__mf__temp \ No newline at end of file +**/.__mf__temp +reports/* +nohup.out \ No newline at end of file diff --git a/.husky/pre-commit b/.husky/pre-commit index 0da96d6..d3ff0bc 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,19 @@ #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" +# Format staged files npx pretty-quick --staged + +# Build project +pnpm build + +# Check if the server is already running on http://localhost:5173 +if ! pnpm exec wait-on http://localhost:5173 --timeout 5000; then + # If not running, start multi-example in the background + pnpm run multi-example & + # Wait for the server to be ready before proceeding + pnpm exec wait-on http://localhost:5173 +fi + +# Run Playwright tests after ensuring the server is up +pnpm playwright test --project=vite-webpack-rspack diff --git a/.vscode/settings.json b/.vscode/settings.json index 3c948a2..71dfd31 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,5 +3,6 @@ "source.organizeImports": "always", "source.fixAll": "always" }, - "editor.formatOnSave": true + "editor.formatOnSave": true, + "cSpell.words": ["microfrontend"] } diff --git a/e2e/nuxt-vite/tests/example.spec.ts b/e2e/nuxt-vite/tests/example.spec.ts index 0aa83d3..c72b88c 100644 --- a/e2e/nuxt-vite/tests/example.spec.ts +++ b/e2e/nuxt-vite/tests/example.spec.ts @@ -1,13 +1,11 @@ import { expect, test } from '@playwright/test'; -test('example.com basic test', async ({ page }) => { - // Go to example.com - await page.goto('https://example.com'); +test('basic test', async ({ page, baseURL }) => { + await page.goto(baseURL!); - // Check the title of the page - await expect(page).toHaveTitle('Example Domain'); + // Get the heading by role with exact name 'Rust Host' + const heading = page.getByRole('heading', { name: 'Nuxt host', exact: true }); - // Check if the heading exists on the page - const heading = page.locator('h1'); - await expect(heading).toHaveText('Example Domain'); + // Expect the heading to be visible + await expect(heading).toBeVisible(); }); diff --git a/examples/rust-vite/rust-host/rsbuild.config.ts b/examples/rust-vite/rust-host/rsbuild.config.ts index 0190b81..ec6c54e 100644 --- a/examples/rust-vite/rust-host/rsbuild.config.ts +++ b/examples/rust-vite/rust-host/rsbuild.config.ts @@ -5,7 +5,7 @@ import { pluginReact } from '@rsbuild/plugin-react'; export default defineConfig({ server: { port: 5172, - open: true, + host: '0.0.0.0', }, dev: { // It is necessary to configure assetPrefix, and in the production environment, you need to configure output.assetPrefix diff --git a/examples/rust-vite/vite-remote/vite.config.js b/examples/rust-vite/vite-remote/vite.config.js index dc41bfc..1fc025a 100644 --- a/examples/rust-vite/vite-remote/vite.config.js +++ b/examples/rust-vite/vite-remote/vite.config.js @@ -6,7 +6,6 @@ import topLevelAwait from 'vite-plugin-top-level-await'; // https://vitejs.dev/config/ export default defineConfig({ server: { - open: true, port: 5173, }, base: 'http://localhost:5173', diff --git a/playwright.config.ts b/playwright.config.ts index 34fc9b2..f461433 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -37,7 +37,7 @@ export default defineConfig({ }, }, { - name: 'vite-webpack-rspack', + name: 'multi-example', testDir: 'e2e/vite-webpack-rspack', use: { baseURL: 'http://localhost:5173', @@ -48,7 +48,7 @@ export default defineConfig({ outputDir: 'reports/e2e/output', reporter: [ ['list'], - ['html', { outputFolder: 'playwright-report', open: 'never' }], - ['json', { outputFile: 'test-results.json' }], + ['html', { outputFolder: 'reports/e2e/playwright-report', open: 'never' }], + ['json', { outputFile: 'reports/e2e/test-results.json' }], ], });