generate-react-cli 8.2.0-alpha.3 → 8.3.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generate-react-cli",
3
- "version": "8.2.0-alpha.3",
3
+ "version": "8.3.0-alpha.1",
4
4
  "description": "A simple React CLI to generate components instantly and more.",
5
5
  "repository": "https://github.com/arminbro/generate-react-cli",
6
6
  "bugs": "https://github.com/arminbro/generate-react-cli/issues",
package/readme.md CHANGED
@@ -478,6 +478,49 @@ GlobalNav.defaultProps = {};
478
478
  export default GlobalNav;
479
479
  ```
480
480
 
481
+ If you have unit testing enabled in your project and have the `withTest` flag enabled, it will generate the unit test file and initialize with some test cases for the generated component right out of the box!
482
+
483
+ Here are the unit tests it generated for the GlobalNav component using the default testing library template (`@testing-library/react`) that comes with GRC.
484
+
485
+ ```tsx
486
+ import React from 'react';
487
+ import { render, screen } from '@testing-library/react';
488
+ import '@testing-library/jest-dom/extend-expect';
489
+ import GlobalNav from './GlobalNav';
490
+
491
+ describe('<GlobalNav />', () => {
492
+ test('it should mount', () => {
493
+ render(<GlobalNav />);
494
+
495
+ const globalNav = screen.getByTestId('GlobalNav');
496
+
497
+ expect(globalNav).toBeInTheDocument();
498
+ });
499
+
500
+ test('it should display the logo "GRC"', () => {
501
+ render(<GlobalNav />);
502
+
503
+ const logo = screen.getByText('GRC');
504
+
505
+ expect(logo).toBeInTheDocument();
506
+ });
507
+
508
+ test('it should display three links: Home, About and Contact', () => {
509
+ render(<GlobalNav />);
510
+
511
+ const homeLink = screen.getByText('Home');
512
+ const aboutLink = screen.getByText('About');
513
+ const contactLink = screen.getByText('Contact');
514
+
515
+ expect(homeLink).toBeInTheDocument();
516
+ expect(aboutLink).toBeInTheDocument();
517
+ expect(contactLink).toBeInTheDocument();
518
+ });
519
+ });
520
+ ```
521
+
522
+ Please note, If you're using a different testing library, you need to provide it as a [custom testing component template](#custom-component-templates), and GRC will instruct openAi to use that to write your unit tests.
523
+
481
524
  That's a wrap. I hope this integration will allow us to generate React components more efficiently, and we can still go in and make the necessary adjustments.
482
525
 
483
526
  Again, please provide any feedback if you have any, and I would love to see some of the components that you generate with GRC+OpenAI.
@@ -24,7 +24,11 @@ export default function initGenerateComponentCommand(args, cliConfigFile, progra
24
24
  'Describe the component you want GRC to generate (e.g., Create a counter component that increments by one when I click on the increment button).',
25
25
  null
26
26
  )
27
- .option('-f, --flat', 'Generate the files in the mentioned path insted of creating new folder for it', false)
27
+ .option(
28
+ '-f, --flat',
29
+ 'Generate the files in the mentioned path instead of creating new folder for it',
30
+ selectedComponentType.flat || false
31
+ )
28
32
  .option('-dr, --dry-run', 'Show what will be generated without writing to disk');
29
33
 
30
34
  // Dynamic component command option defaults.