Search code examples
angularjsunit-testingkarma-jasmine

Is it a way to generate karma unit test for Angular?


I used to unit test my AngularJS application using Jasmine and Karma. I would like to know if is it a way to generate dynamically karma unit test files.

By the way is it a good thing to generate (or try so) unit test files or is it preferable to do it manually ?


Solution

  • If you want to auto generate the angular unit test for components , services, pipes, directives you can use this

    npm i ai-test-gen-angular
    export OPENAI_API_KEY=somekey
    node ./node_modules/ai-test-gen-angular/index.js "relative/path/to/service/or/somecomponent.component.ts" "relative/path/to/tsconfig.json" 
    

    You will need to have a OpenAi api key to use this Library as it uses open ai i.e. generative AI technology to create unit tests.