Codium-ai / codiumai-vscode-release

266 stars 37 forks source link

Tests are generated with `jest` even when selecting `vitest` as test framework #118

Closed antoniolofiego closed 8 months ago

antoniolofiego commented 10 months ago

Independently of the test framework I choose (my target is Vitest), all the tests are generated using Jest and consequently fail, even after fixing and retrying. Tried with multiple functions, multiple files and multiple combinations of other options.

almog-lv commented 10 months ago

Hey @antoniolofiego, thanks for opening this issue! Can I ask you to provide more information:

  1. RequestID (you can click on CodiumAI logo in the upper left side of the panel and choose "Copy Request ID")
  2. If you can provide the code you are trying to fix / screenshot of the results

Also, is the problem you have that you can't run the tests? If yes, can you please paste here the failure description?

Thank you for that!

antoniolofiego commented 10 months ago

Hey @antoniolofiego, thanks for opening this issue! Can I ask you to provide more information:

  1. RequestID (you can click on CodiumAI logo in the upper left side of the panel and choose "Copy Request ID")
  2. If you can provide the code you are trying to fix / screenshot of the results

Also, is the problem you have that you can't run the tests? If yes, can you please paste here the failure description?

Thank you for that!

Hey @almog-lv, here are the details.

Request ID: 13474a24-26a4-4ee0-9cc7-095500732de6

This is the generated test:

   it('should render children when flag is enabled', () => {
      // Mock the useFlags function to return a flags object with the specified flag set to true
      jest.mock('../services/launchDarkly', () => ({
        useFlags: jest.fn(() => ({ [flag]: true })),
      }));

      // Import the component
      const { FeatureFlagWrapper } = require('../components/FeatureFlagWrapper');

      // Render the component with the flag enabled
      const { getByText } = render(
        <FeatureFlagWrapper flag={flag}>
          <div>Children</div>
        </FeatureFlagWrapper>
      );

      // Assert that the children are rendered
      expect(getByText('Children')).toBeInTheDocument();
    });

The key error is that it's generating Jest code when the configuration is for Vitest, screenshot here.

image
james-gough-op commented 8 months ago

I'm not even offered Vitest in the config screen anymore. I can set it in the config file but it's ignored.

almog-lv commented 8 months ago

Hey @james-gough-op thanks for reporting, Vitest is relatively new, and current AI models, including ours, did not have Vitest data in their training set. It will probably be resolved in the 2-3 months with newer models, but in the meantime we removed Vitest from the list of possible frameworks. It will be added back once it will be supported.