By default, when you use
hc init to create a new project folder, it creates a sub-directory called
test. The files in that folder are equipped for testing your project. The contents of the folder represent a simple nodejs package (in that they have a
index.js file and a
Tools to help with testing are also built right into the development command line tools.
Once you have a project folder initiated, you can run
hc test to execute your tests. This combines the following steps:
1. Packaging your files into a DNA file, located at
dist/your.dna.json. This step will fail if your packaging step fails.
2. Installing build and testing dependencies, if they're not installed (
3. Executing the test file found at
The tests can of course be called manually using nodejs, but you will find that using the convenience of the
hc test command makes the process much smoother, since it includes the packaging step for when you change the DNA source files.
hc test also has some configurable options.
If you want to run it without repackaging the DNA, run it with
hc test --skip-package
If your tests are in a different folder than
test, run it with
hc test --dir tests
testsis the name of the folder.
If the file you wish to actually execute is somewhere besides
test/index.js then run it with
hc test --testfile test/test.js
test/test.jsis the path of the file.