You should be able to use this guide to...
- Check code linting and style
- Run and write unit tests
- Run and write functional tests
- Learn how to write tests
Lando implements some basic linting and a slightly less annoying version of the
es6 code standards to make sure things remain consistent between developers and to prevent syntax errors. You can easily check whether your code matches these standards using grunt.
In order to familiarize yourself with where tests should live for both core and plugins please consult the structure guide. Lando's core libraries currently have decent coverage so you can scope them out for help writing tests.
To run the unit test suite, execute:
Lando uses it's own functional testing framework called leia. Leia helps us ensure that Lando is the real hero we all know him to be.
mocha as the test runner,
chai for assertions and
command-line-test to make the process of executing commands simpler. Tests are written as specially structured
README.md files that live in the
examples folder and contain code blocks. When the suite runs these are scanned, parsed and outputted as mocha tests.
Pretty sure these will not run on Windows yet
SORRY WINDOZE USERS!
To generate tests from the
examples repo and then run the functional test suite, execute:
yarn generate-tests && yarn test:functional
NOTE: This may take awhile to complete locally and could destroy any apps you may already have running. It's best to use it in a continuos integration environment.
To better understand how these
markdown files need to be parsed check out the Leia docs. Lando will specifically look for headers that start with the following to determine which kinds of tests your code block is for:
Here are some caveats and general guidelines about when and how to write functional tests.
- The suite will run against the
landoit finds in your PATH so you need to make sure that
landois running from source
- For test commands to pass they must return a 0 status code eg not have any errors
- Additional quotes inside of a
lando ssh -c "STUFF"are not handled very well right now
When you are fixing a bug, you should first write a test to confirm the bug exists repeatably, then you can fix the bug, and the test should pass. Because this framework is essentially just running a bunch of Lando and/or Docker commands it should be pretty easy to write out steps to replicate using the framework.
- Your PR is docs only
- Your PR is outside the critical path (writing tests, altering our build pipeline)
- Your code alters Lando in a way that doesn't alter the 'contract' with the user. Internal refactoring should add or alter appropriate unit tests, but if the net affect is not visible to an end user, it doesn't need a functional test.
In addition to the tips above, looking at existing tests will give you a good idea of how to write your own, but if you're looking for more tips, we recommend: