# Writing IO tests
Another way we can write tests with Counsel is using Input/Output (IO) tests. The example will show basic conventions and steps for writing IO tests with Counsel:
IO tests are written in yaml files.
IO test file names need to end with *Test.yaml.
The most basic IO test will require the following fields:
test- a short description about what you want to testperform- the input, command to runexpect- what should be the output
- Optional fields for an IO test:
cwd- specify the current working directory the testplatform- specify one or more platforms within this test should runskip- mark the IO test as skippedassertions- specify basic true/false expectations
# Example
Example 2.1 - Testing the famous ls command with Counsel.
test: |
"ls" command test
cwd: tests/doubles/ls-dir
perform: |
ls
expect: |
bar.txt
baz.txt
foo.txt
sub-1
assertions:
status: 0
# Real-world Counsel IO test example
test:
Dot reporter error true and false output
perform:
src/counsel.js --config dot-reporter-true-false-reporting-test.js --is-io-test
expect: |
Counsel {{version}}
xx 2 / 2 (100%)
x 1) CoreAssertionsTest -> it_is_able_to_assert_true
{{root}}io-tests/dot-reporter-true-false-test/CoreAssertionsTest.js:6
5| {
6| this.assertTrue(false);
7| }
Value is not truthy:
false
x 2) CoreAssertionsTest -> it_is_able_to_assert_false
{{root}}io-tests/dot-reporter-true-false-test/CoreAssertionsTest.js:12
11| {
12| this.assertFalse(true);
13| }
Value is not falsy:
true
Time: {{executionTimeFormatted}}
2 failed, 2 tests
assertions:
status: 2
assertionsCount: 2
assertionsFailuresCount: 2
assertionsPassesCount: 0
testsCount: 2
testsFailuresCount: 2
testsPassesCount: 0
progress: 100