From 6efac0fe6f8b7cc29731f1243c791fb7204f254e Mon Sep 17 00:00:00 2001 From: Kayla Altepeter Date: Sun, 3 Apr 2022 08:59:03 -0500 Subject: [PATCH 1/2] fix(react): case sensitive file import with react app generator when using pascalCaseFiles option Based on the flags passed into the react application generator it should use the appropiate casing in the imports for the generated App.spec.tsx. This only affected new react apps generated with the `--pascalCaseFiles` flag on fully case sensitive file systems, such as a linux host running docker linux. Since it's likely people have already manually fixed, I don't think a migration makes sense. fixes #9666, closes nrwl/nx-examples#195 ISSUES CLOSED: #9666 --- .../application/application.spec.ts | 20 +++++++++++++++++++ .../src/app/__fileName__.spec.tsx__tmpl__ | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/react/src/generators/application/application.spec.ts b/packages/react/src/generators/application/application.spec.ts index d03f3d4f2279e..beab116c056a7 100644 --- a/packages/react/src/generators/application/application.spec.ts +++ b/packages/react/src/generators/application/application.spec.ts @@ -399,6 +399,16 @@ Object { expect(appTree.exists('apps/my-app/src/app/App.spec.tsx')).toBeTruthy(); expect(appTree.exists('apps/my-app/src/app/App.module.css')).toBeTruthy(); }); + + it(`should use the correct case for file import in the spec file`, async () => { + await applicationGenerator(appTree, { ...schema, pascalCaseFiles: true }); + + const appSpecContent = appTree + .read('apps/my-app/src/app/App.spec.tsx') + .toString(); + + expect(appSpecContent).toMatch(/import App from '.\/App'/); + }); }); it('should generate functional components by default', async () => { @@ -409,6 +419,16 @@ Object { expect(appContent).not.toMatch(/extends Component/); }); + it(`should use the correct case for file import in the spec file`, async () => { + await applicationGenerator(appTree, { ...schema }); + + const appSpecContent = appTree + .read('apps/my-app/src/app/app.spec.tsx') + .toString(); + + expect(appSpecContent).toMatch(/import App from '.\/app'/); + }); + it('should add .eslintrc.json and dependencies', async () => { await applicationGenerator(appTree, { ...schema, linter: Linter.EsLint }); diff --git a/packages/react/src/generators/application/files/common/src/app/__fileName__.spec.tsx__tmpl__ b/packages/react/src/generators/application/files/common/src/app/__fileName__.spec.tsx__tmpl__ index cb810d67d8c66..86f0708d4445b 100644 --- a/packages/react/src/generators/application/files/common/src/app/__fileName__.spec.tsx__tmpl__ +++ b/packages/react/src/generators/application/files/common/src/app/__fileName__.spec.tsx__tmpl__ @@ -3,7 +3,7 @@ import { render } from '@testing-library/react'; import { BrowserRouter } from 'react-router-dom'; <% } %> -import App from './app'; +import App from './<%= fileName %>'; describe('App', () => { it('should render successfully', () => { From 8055e6e19bff111935933aab75b44634270ca2bc Mon Sep 17 00:00:00 2001 From: Craigory Coppola Date: Tue, 5 Apr 2022 09:35:06 -0400 Subject: [PATCH 2/2] chore(repo): kick off CI