From 392b4b82bc2dfc6580b089e8bdf1a4067ca76588 Mon Sep 17 00:00:00 2001 From: Colum Ferry Date: Fri, 13 Sep 2024 10:38:14 +0100 Subject: [PATCH] chore(react): add rspack bundler test --- e2e/react/src/react.test.ts | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/e2e/react/src/react.test.ts b/e2e/react/src/react.test.ts index 043bf20b1f..c0865cc177 100644 --- a/e2e/react/src/react.test.ts +++ b/e2e/react/src/react.test.ts @@ -63,6 +63,41 @@ describe('React Applications', () => { } }, 250_000); + it('should be able to use Rspack to build and test apps', async () => { + const appName = uniq('app'); + const libName = uniq('lib'); + + runCLI( + `generate @nx/react:app ${appName} --bundler=rspack --unit-test-runner=vitest --no-interactive --skipFormat` + ); + runCLI( + `generate @nx/react:lib ${libName} --bundler=none --no-interactive --unit-test-runner=vitest --skipFormat` + ); + + // Library generated with Vite + checkFilesExist(`libs/${libName}/vite.config.ts`); + + const mainPath = `apps/${appName}/src/main.tsx`; + updateFile( + mainPath, + ` + import '@${proj}/${libName}'; + ${readFile(mainPath)} + ` + ); + + runCLI(`build ${appName}`); + + checkFilesExist(`dist/apps/${appName}/index.html`); + + if (runE2ETests()) { + // TODO(Colum): investigate why webkit is failing + const e2eResults = runCLI(`e2e ${appName}-e2e --project=chromium`); + expect(e2eResults).toContain('Successfully ran target e2e for project'); + expect(await killPorts()).toBeTruthy(); + } + }, 250_000); + it('should be able to generate a react app + lib (with CSR and SSR)', async () => { const appName = uniq('app'); const libName = uniq('lib');