Keep Lando honest so he can be a real hero who doesn't betray his friends again

A very basic example of what leia will do

Some Example
============
Testing
------
# A description of my test
the command i am running

becomes

/* * This file was automatically generated, editing it manually would be foolish * * See https://github.com/lando/leia for more * information on how all this magic works * * id: example * runs-from: ..*/// We need these deps to run our teztsconstchai=require('chai');
constCliTest=require('command-line-test');
constpath=require('path');
chai.should();
// eslint-disable max-lendescribe('example', function() {
this.retries(3);
// These tests are the main event// @todo: It would be nice to eventually get these into mocha after hooks// so they run after every testit('a description of my test', done=> {
process.chdir(path.resolve(__dirname, '..'));
constcli=newCliTest();
cli.exec('the command i am running').then(res=> {
if (res.error===null) {
done();
} else {
done(res.error);
}
});
});
});

Installing

We recommend you use the LTS 10.x version of nodejs and the latest yarn. An easy way to get all the deps you need for leia is to look at the Hyperdrive. We do not recommend installing leia globally.

yarn add leia-parser

Usage

You can invoke leia-parser as a command line tool or directly require it in a module.

Markdown Syntax

In order for your markdown file to be recognized as containing functional tests it needs to have at least the following

1. A h1 Header

Something to identify these tests
=================================

2. A h2 Header

Our parser will look for a section that beings with the word "Testing". This section will contain your tests.

Testing
-------

You can customize the word(s) that leia will look for to identify the testing section(s) using the --test-header option. You can also run yarn leia --help to get a list of default words.

3. A code block with at least one command and comment

Under the above h2 sections you need to have a triple tick markdown code block that contains at least one comment and one command. The comment will be the human readable description of what the test does.

Here is a basic code block that runs one test

# Should cat a file
cat test.txt

If you want to learn more about the syntax and how leia puts together the above, check out this example

Advanced Usage

Leia also allows you to specify additional h2 sections in your markdown for setup and cleanup commands that run before and after your core tests. You can tell leia what words these headers should start with in order to be flagged as setup and cleanup commands using the --setup-header and --cleanup-header options.

Here is an example of a markdown file with Setup, Testing and Cleanup sections.