1.9.5 • Published 1 month ago

deepunit v1.9.5

Weekly downloads
-
License
http://deepunit.a...
Repository
-
Last release
1 month ago

DeepUnit.AI

AI-Powered Unit Test Generation, provided by https://deepunit.ai. DeepUnitAi will generate your tests for you, guaranteeing valid code everytime.

Table of Contents

Release State

Currently in Alpha release.

Currently only supported on Linux, MacOS, and Windows throughWSL (native Windows is unsupported currently)

The application generates working tests fairly consistently, but does require a lot of supervision from user currently.

Users are expected to always review tests that are generated for correctness before committing them.

Usage

You can use DeepUnit without installing it by running the command npx deepunit --f path/to/file.ts

Authentication

For a seamless experience with DeepUnit.Ai, we ask users to provide a valid email upon the initial application setup. This email serves as your identifier across all your git repositories and is saved in the ~/.deepunit file. If ever you wish to update your email, simply delete the .deepunit file in your home directory and restart the application.

Config

DeepUnits config is stored in a file called deepunit.config.json which is automatically created for you. We support the following configs.

{
  // Force what the frontendframework is (react, node, angular, etc) in case we detect it wrong
  "frontendFramework": "react"

  // We default to Jasmine if we are unable to detect your testing framework. This config forces sets the testing framework. This config is helpful if we are unable to detect that you are using jest or you use a Jest compatible framework like Vitest. 
  "testingFramework": "jest"

  // Which directories you want to ignore, path is from the root of the project. In case of a monorepo it is the root of the package.json deepunit is installed in.
  "ignoredDirectories": [],

  // Which files you want to ignore
  "ignoredFiles": ["src/main.consts.ts", "src/utils.ts", "src/Config.ts"],

  // when all tests for a file fail, this option allows DeepUnit.AI to save the failing tests to a file so that you fix them manually
  "includeFailingTests": false,

  // what gets added between the name of file and the extension. Example if set to 'spec': Utils.ts -> Utils.spec.ts (default set to test)
  "testSuffix": "test",

  // What language you want the tests to generate in (forcing it to be a specific language)
  // Options are "javascript" or "typescript" right now
  "testingLanguageOverride": "javascript",

  // we use git to get diffs from the default branch. The default is master unless configured here.
  "defaultBranch": "main"

  // Specify the type/goal of testcases you want to cover. Examples are happy path, edgecase, 80% code coverage, detect bugs, etc.
  "testCaseGoal": "edge cases"
  
  // If you have a monorepo and the directory of this project is not the root please list the directory path. Leave this blank otherwise
  "monorepoDirectory": "repos/projectToTest"
  
  // Choose to use either OpenAIs models or open source models such as Mixtral or LLaMa
  "useOpenAi": false
}

Provide additional testing/debugging instructions to AI model

To provide more specific instructions to the AI model (problems, testing paths, edge cases to look for), simply provide a comment at the top or your source code file beginning with 'deepunit-prompt-start' and ending with 'deepunit-prompt-end'

Flags for identifying bugs

You can identify bugs with the --b flag. The --b flag will take in a file path and identify if there are potential bugs in it and return to you a bug report including a unit tests that identifies the bug npx deepunit --b path/to/file.ts

Flags for writing unit tests

To choose what to test, you have a few options

  • Use the --file flag to choose what files you would like to test (the files should be separated by a ",")

npx deepunit --f path/to/file.ts,path/to/second.ts

  • Use the --pattern flag to choose what patterns you would like to filter files for. We use glob under the hood (Example: src/** or {lib,src}/*{.ts,.js}), for more information about pattern matching visit: VSCode Glob Matching

npx deepunit --p {lib,src}/*{.ts,.js}

  • Use the --all flag to do generate tests for all eligible files in the workspace.

npx deepunit --a

  • Without any flag, it will look at the last diff and attempt to write tests for the files in the diff.

npx deepunit

Ignoring files

There will be certain directories, files or functions in your project which you won't want to test. You can configure DeepUnit to ignore these files or entire directories using the following configs in deepunit.config.json

  • ignoredDirectories will ignore an entire directory
  • ignoredFiles will ignore specific files
  • // @deep-unit-ignore-next-line will ignore a function, method, or entire class. Add this inside your code just like you would @ts-ignore
// @deep-unit-ignore-next-line
function example(): void {
  // ... other code
}
// @deep-unit-ignore-next-line
class NoneTestableClass() {
  example(): void {
    // ... other code
  }
}

Note: DeepUnit.Ai intelligently skips functions that already have tests in the corresponding test files. If you encounter issues generating a test for a specific function, ensure that it hasn't been tested elsewhere in the file.

Contact

If you have any questions, please contact support@deepunit.ai for more details.

1.9.5

1 month ago

1.9.4

1 month ago

1.9.3

2 months ago

1.9.2

3 months ago

1.9.1

3 months ago

1.9.0

3 months ago

1.8.8

4 months ago

1.8.7

5 months ago

1.8.6

5 months ago

1.8.5

5 months ago

1.8.4

5 months ago

1.8.3

5 months ago

1.8.2

5 months ago

1.8.1

5 months ago

1.8.0

5 months ago

1.7.1

6 months ago

1.7.0

6 months ago

1.6.3

6 months ago

1.6.2

6 months ago

1.6.1

6 months ago

1.6.0

6 months ago

1.5.3

6 months ago

1.5.2

7 months ago

1.5.1

7 months ago

1.5.0

7 months ago

1.4.1

7 months ago

1.4.0

7 months ago

1.3.4

7 months ago

1.3.3

7 months ago

1.3.2

7 months ago

1.3.1

7 months ago

1.3.0

7 months ago

1.2.0

7 months ago

1.1.4

8 months ago

1.1.3

8 months ago

1.1.2

8 months ago

1.1.1

8 months ago

1.1.0

8 months ago

1.0.7

8 months ago

1.0.6

8 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago