The tests in this folder are run via gulp karma
and will be executed in a browser.
Tests for the Blockly compiler take a .blocks
file as input and compare
the output against a baseline .ts
file. To generate those files:
- Add the required block definitions in the
test-library
directory. Make sure you add the.ts
file you create topxt.json
. Note: do not add any C++ files, this library only accepts TypeScript! - Create the
.blocks
file for the test. There is no easy way to do it, but this is the method I follow: a. Copy the code you added in step 1 to some target (likepxt-sample
) b. Runpxt serve
in that target and create your test case in the editor c. Inside theprojects
directory of that target, a directory should have been created for the new project you just made in the editor. Grab themain.blocks
file from that directory. - Place the
.blocks
file in thecases
subdirectory. - Add the expected result
.ts
file with the same name (but different file extension) to thebaselines
directory - In
test.spec.ts
, add a test case for your new files. Copy the other ones in that file and give it a relevant message.