Closed pke closed 4 years ago
pta now wants me to export my test which makes them lose this before mentioned benefit of being runnable files
Yes pta is a bit more opiniated and relies on some conventions. It needs to create its own test harness to manage reporting, exit code and some others features whereas we want a test file to be platform agnostic.
Is there no way to just evaluate the file content and filter the output? In non-esm files pta could just load the files content into a Function object and run that. Of course that does not work when the file uses imports, as imports can not be used on function level (contrary to require).
As you mentioned your solution won't work in all cases.
A solution would be to make pta modifies(mutates) zora's exports with its own test harness but that is a dangerous path to follow. Another one would be to make pta reexport its test harness as assertion library and the consuming code requires it in place of zora
import {test} from 'pta';
//etc
However this bothers me a bit because it creates an unnecessary dependency to a Nodejs specific module and would be troublesome for programs intended to run in the browser or both environments. I am currently in the process of writing a test runner for the browser with the same conventions so a same test program could run in node with pta and in the browser with this tool.
I personally don't find your situation that troublesome: I don't know much about VSCode but my IDE allows me to setup quickly a debug config from a file.
Another acceptable workaround can be to create your own "test runner", something as simple as
// some untracked file ./test/index.js
const {test} = require( 'zora'); // use directly zora: reporting does not matter much when in a debug
const spec = require('path/to/file/to/debug.js');
test(`debug`, spec);
And debug that file !
Yeah I can try something like that, thanks for the suggestions.
The main benefit of
zora
is (like node-tap test files) that is a simple ECMAscript file that can be run just by node. That also makes it very easy to debug (in VSCode). I can just put a breakpoint in a test and run the file in the debugger.pta
now wants me to export my test which makes them lose this before mentioned benefit of being runnable files.Is there no way to just evaluate the file content and filter the output? In non-esm files
pta
could just load the files content into aFunction
object and run that. Of course that does not work when the file uses imports, as imports can not be used on function level (contrary torequire
).