gemini-testing / testplane

Testplane (ex-hermione) browser test runner based on mocha and wdio
https://testplane.io
MIT License
687 stars 62 forks source link

feat: implement new cli command to read tests #986

Closed DudaGod closed 3 days ago

DudaGod commented 1 month ago

What is done

Implement ability to read tests using cli command npx testplane list-tests which support options like for run tests:

The formatter supports 2 values: list (default) and tree. When using list user get plain list of unique tests, example:

[
    {
        "id": "5a105e8",
        "titlePath": [
            "test1"
        ],
        "browserIds": [
            "yandex",
            "chrome"
        ],
        "file": "tests/second.hermione.js",
        "pending": false,
        "skipReason": ""
    },
    {
        "id": "d2b3179",
        "titlePath": [
            "suite",
            "test2"
        ],
        "browserIds": [
            "yandex",
            "chrome"
        ],
        "file": "tests/second.hermione.js",
        "pending": false,
        "skipReason": ""
    }
]

The same data in tree formatter looks like:

[
    {
        "id": "36749990",
        "title": "suite",
        "line": 3,
        "column": 1,
        "file": "example.hermione.js",
        "suites": [],
        "tests": [
            {
                "id": "d2b3179",
                "title": "test2",
                "line": 4,
                "column": 5,
                "browserIds": [
                    "yandex"
                ],
                "pending": false,
                "skipReason": ""
            }
        ],
        "pending": false,
        "skipReason": ""
    },
    {
        "id": "5a105e8",
        "title": "test1",
        "line": 1,
        "column": 1,
        "browserIds": [
            "yandex"
        ],
        "file": "example.hermione.js",
        "pending": false,
        "skipReason": ""
    }
]

the important difference is that the tree formatter supports line and column fields. They can be used to find out exactly where the suite or test is declared in the file. It will be used in vscode extension.


The same output is supported via API - testCollection.format(<type>)