Skip to content

Commit

Permalink
chore(react): add rspack bundler test
Browse files Browse the repository at this point in the history
  • Loading branch information
Coly010 committed Sep 18, 2024
1 parent c544a34 commit ef80f63
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions e2e/react/src/react.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 --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');
Expand Down

0 comments on commit ef80f63

Please sign in to comment.