Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests: Pretty-printed token stream #1801

Merged

Conversation

RunDevelopment
Copy link
Member

This adds support for pretty-printed simplified token streams via the --pretty modifier.
E.g. npm test -- --pretty or npm test -- --language=xxxx --pretty

Only the current token stream of failed tests will be pretty-printed. This can then be copypasted into .test-files.
Because most consoles convert tabs into 8 spaces, I used 4 spaces for indentation.

This should make writing tests a lot more comfortable.

Example

Now:

[["tag",[["tag",[["punctuation","<"],"div"]],["attr-name",["class"]],["attr-value",[["punctuation","="],["punctuation","\""],"test",["punctuation","\""]]],["attr-name",["foo"]],["attr-name",["bar"]],["attr-value",[["punctuation","="],"baz"]],["punctuation",">"]]]]

Pretty:

[
    ["tag", [
        ["tag", [
            ["punctuation", "<"],
            "div"
        ]],
        ["attr-name", [
            "class"
        ]],
        ["attr-value", [
            ["punctuation", "="],
            ["punctuation", "\""],
            "test",
            ["punctuation", "\""]
        ]],
        ["attr-name", [
            "foo"
        ]],
        ["attr-name", [
            "bar"
        ]],
        ["attr-value", [
            ["punctuation", "="],
            "baz"
        ]],
        ["punctuation", ">"]
    ]]
]

Copy link
Member

@mAAdhaTTah mAAdhaTTah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nit but gtg

tests/helper/token-stream-transformer.js Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants