From 8e7aa32f854ade80e8dcca80b39c04a6bcbfb125 Mon Sep 17 00:00:00 2001 From: Jack Hsu Date: Fri, 3 Mar 2023 09:55:49 -0500 Subject: [PATCH] fix(rspack): use correct app dir when generating non-root projects (#162) --- tests/rspack.spec.ts | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/rspack.spec.ts b/tests/rspack.spec.ts index 9480525ffc..66ca918736 100644 --- a/tests/rspack.spec.ts +++ b/tests/rspack.spec.ts @@ -1,4 +1,5 @@ import { + checkFilesExist, ensureNxProject, listFiles, runNxCommandAsync, @@ -23,7 +24,7 @@ describe('rspack e2e', () => { runNxCommandAsync('reset'); }); - it('should create rspack project', async () => { + it('should create rspack root project and additional apps', async () => { const project = uniq('myapp'); await runNxCommandAsync( `generate @nrwl/rspack:preset ${project} --unitTestRunner=jest --e2eTestRunner=cypress` @@ -54,5 +55,27 @@ describe('rspack e2e', () => { }); expect(result.stdout).toContain('Successfully ran target build'); expect(listFiles(`dist/${project}`)).toHaveLength(5); // same length as before + + // Generate a new app and check that the files are correct + const app2 = uniq('app2'); + await runNxCommandAsync( + `generate @nrwl/rspack:app ${app2} --unitTestRunner=jest --e2eTestRunner=cypress --style=css` + ); + checkFilesExist(`${app2}/project.json`, `${app2}-e2e/project.json`); + result = await runNxCommandAsync(`build ${app2}`, { + env: { NODE_ENV: 'production' }, + }); + expect(result.stdout).toContain('Successfully ran target build'); + // Make sure expected files are present. + expect(listFiles(`dist/${app2}`)).toHaveLength(5); + + result = await runNxCommandAsync(`lint ${app2}`); + expect(result.stdout).toContain('Successfully ran target lint'); + + result = await runNxCommandAsync(`test ${app2}`); + expect(result.stdout).toContain('Successfully ran target test'); + + result = await runNxCommandAsync(`e2e ${app2}-e2e`); + expect(result.stdout).toContain('Successfully ran target e2e'); }, 120_000); });