Testing your source code via the CLI
Snyk Code enables you to test the source code of your repositories via the Snyk CLI.
Notes:
When testing a folder, all its sub-folders and files will be tested as well.
To exclude certain directories or files from the Snyk Code CLI test, you can use the following Exclusion methods:
Using the CLI
snyk ignore --file-path
command – see Excluding directories and files from the Snyk Code test.Manually creating a
.snyk
file in the tested folder – see Excluding directories and files from the import process.
When testing your repository code via the CLI, you can:
Test the repository directly from its root folder (see below).
Testing a repository from its root folder
To test the current repository folder:
In the terminal, enter:
snyk code test
Note: No additional parameters are required for running Snyk Code to test a repository from its root folder.
Snyk Code tests the current folder, and displays the test results in the terminal.
For example:
To test the snyk-goof repository from its root folder, we first changed the directory to the root folder of the repository. Then, we enter:
snyk code test
Snyk Code tests the snyk-goof repository, and displays the vulnerability issue that were discovered in the terminal:

Testing a repository from a different location
To test a repository from another folder:
In the terminal, enter:
snyk code test <path/to/folder>
Where:
path/to/folder
– the full path of the repository you want to test via Snyk Code.
For example:
To test the snyk-goof repository from another directory, we enter:
snyk code test /Users/username/Documents/Repositories/snyk-goof

To explore the test results, see Understanding the Snyk Code CLI results.
Last updated
Was this helpful?