Possible to run AVA tests inside a node server?

461 views Asked by At

I want users to submit code and run tests against that code using AVA. The AVA CLI seems great. But this would be running in a hosted environment like Heroku and need to respond back to the POST request containing the code submission with the results of the unit tests.

When I try var test = require('ava') and then call the test function in a route, I get this message when starting the node server:

[OKAY] Loaded ENV .env File as KEY=VALUE Format
10:24:11 PM web.1 |  Test files must be run with the AVA CLI:
10:24:11 PM web.1 |      $ ava index.js
[DONE] Killing all processes with signal  null
10:24:11 PM web.1 Exited with exit code 1
1

There are 1 answers

0
Antonio Val On BEST ANSWER

I think it is not possible, it is thought to be used through the cli. Actually to me it does not make much sense for it be used as a required module in your code.

How did you plan to use it? If you just want to use the assertions you can use some assertion library like chai, expect or power-assert.

If you want more information opening an issue in the AVA repo also could be an option.