From b18fc61d8b3a6f0a350d4d62a6f4eeb3d5862f5e 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 | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/e2e/react/src/react.test.ts b/e2e/react/src/react.test.ts index 043bf20b1f09b0..1cc8788eb97d8f 100644 --- a/e2e/react/src/react.test.ts +++ b/e2e/react/src/react.test.ts @@ -63,6 +63,40 @@ 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()) { + const e2eResults = runCLI(`e2e ${appName}-e2e`); + 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');