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

Chore: fix formatters/table test #11534

Merged
merged 1 commit into from Mar 22, 2019
Merged

Conversation

mysticatea
Copy link
Member

What is the purpose of this pull request? (put an "X" next to item)

[X] Other, please explain

What changes did you make? (Give an overview)

If standalone mocha command ran tests/lib/formatters/table.js, coloring caused to fail the tests.
$ mocha tests/lib/formatters/table

  formatter:table
    when passed no messages
      1) should return a table of error and warning count with no messages
    when passed a single message
      2) should return a string in the correct format for errors
      3) should return a string in the correct format for warnings
    when passed a fatal error message
      4) should return a string in the correct format
    when passed multiple messages
      5) should return a string with multiple entries
    when passed multiple files with 1 message each
      6) should return a string with multiple entries
    when passed one file not found message
      7) should return a string without line and column (0, 0)


  0 passing (59ms)
  7 failing

  1) formatter:table
       when passed no messages
         should return a table of error and warning count with no messages:

      AssertionError: expected '\n╔════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗\n║ \u001b[31m0 Errors\u001b[39m                                                                                                       ║\n╟────────────────────────────────────────────────────────────────────────────────────────────────────────────────╢\n║ \u001b[33m0 Warnings\u001b[39m
                ║\n╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝\n' to equal '\n╔════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗\n║ 0 Errors
                                ║\n╟────────────────────────────────────────────────────────────────────────────────────────────────────────────────╢\n║ 0 Warnings
                                                                                           ║\n╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝\n'
      + expected - actual


       ╔════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
      -║ 0 Errors                                                                                                       ║
      +║ 0 Errors                                                                                                       ║
       ╟────────────────────────────────────────────────────────────────────────────────────────────────────────────────╢
      -║ 0 Warnings                                                                                                     ║
      +║ 0 Warnings                                                                                                     ║
       ╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝

      at Context.it (tests\lib\formatters\table.js:42:20)

  2) formatter:table
       when passed a single message
         should return a string in the correct format for errors:

      AssertionError: expected '\nfoo.js\n\n║ \u001b[1mLine\u001b[22m     │ \u001b[1mColumn\u001b[22m   │ \u001b[1mType\u001b[22m     │ \u001b[1mMessage\u001b[22m
                                     │ \u001b[1mRule ID\u001b[22m              ║\n╟──────────┼──────────┼──────────┼────────────────────────────────────────────────────────┼──────────────────────╢\n║ 5        │ 10       │ \u001b[31merror\u001b[39m    │ Unexpected foo.                                        │ foo                  ║\n\n╔════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗\n║ \u001b[31m1 Error\u001b[39m
                                                                  ║\n╟────────────────────────────────────────────────────────────────────────────────────────────────────────────────╢\n║ \u001b[33m0 Warnings\u001b[39m                                                                                                     ║\n╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝\n' to equal '\nfoo.js\n\n║ Line     │ Column   │ Type     │ Message
                                │ Rule ID              ║\n╟──────────┼──────────┼──────────┼────────────────────────────────────────────────────────┼──────────────────────╢\n║ 5        │ 10       │ error    │ Unexpected foo.                                        │ foo                  ║\n\n╔════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗\n║ 1 Error
  ║\n╟────────────────────────────────────────────────────────────────────────────────────────────────────────────────╢\n║ 0 Warnings
                                                             ║\n╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝\n'
      + expected - actual


       foo.js

      -║ Line     │ Column   │ Type     │ Message                                                │ Rule ID              ║
      +║ Line     │ Column   │ Type     │ Message                                                │ Rule ID              ║
       ╟──────────┼──────────┼──────────┼────────────────────────────────────────────────────────┼──────────────────────╢
      -║ 5        │ 10       │ error    │ Unexpected foo.                                        │ foo                  ║
      +║ 5        │ 10       │ error    │ Unexpected foo.                                        │ foo                  ║

       ╔════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
      -║ 1 Error                                                                                                        ║
      +║ 1 Error                                                                                                        ║
       ╟────────────────────────────────────────────────────────────────────────────────────────────────────────────────╢
      -║ 0 Warnings                                                                                                     ║
      +║ 0 Warnings                                                                                                     ║
       ╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝

      at Context.it (tests\lib\formatters\table.js:83:20)

  3) formatter:table
       when passed a single message
         should return a string in the correct format for warnings:

      AssertionError: expected '\nfoo.js\n\n║ \u001b[1mLine\u001b[22m     │ \u001b[1mColumn\u001b[22m   │ \u001b[1mType\u001b[22m     │ \u001b[1mMessage\u001b[22m
                                     │ \u001b[1mRule ID\u001b[22m              ║\n╟──────────┼──────────┼──────────┼────────────────────────────────────────────────────────┼──────────────────────╢\n║ 5        │ 10       │ \u001b[33mwarning\u001b[39m  │ Unexpected foo.                                        │ foo                  ║\n\n╔════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗\n║ \u001b[31m0 Errors\u001b[39m
                                                                  ║\n╟────────────────────────────────────────────────────────────────────────────────────────────────────────────────╢\n║ \u001b[33m1 Warning\u001b[39m                                                                                                      ║\n╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝\n' to equal '\nfoo.js\n\n║ Line     │ Column   │ Type     │ Message
                                │ Rule ID              ║\n╟──────────┼──────────┼──────────┼────────────────────────────────────────────────────────┼──────────────────────╢\n║ 5        │ 10       │ warning  │ Unexpected foo.                                        │ foo                  ║\n\n╔════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗\n║ 0 Errors
  ║\n╟────────────────────────────────────────────────────────────────────────────────────────────────────────────────╢\n║ 1 Warning
                                                             ║\n╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝\n'
      + expected - actual


       foo.js

      -║ Line     │ Column   │ Type     │ Message                                                │ Rule ID              ║
      +║ Line     │ Column   │ Type     │ Message                                                │ Rule ID              ║
       ╟──────────┼──────────┼──────────┼────────────────────────────────────────────────────────┼──────────────────────╢
      -║ 5        │ 10       │ warning  │ Unexpected foo.                                        │ foo                  ║
      +║ 5        │ 10       │ warning  │ Unexpected foo.                                        │ foo                  ║

       ╔════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
      -║ 0 Errors                                                                                                       ║
      +║ 0 Errors                                                                                                       ║
       ╟────────────────────────────────────────────────────────────────────────────────────────────────────────────────╢
      -║ 1 Warning                                                                                                      ║
      +║ 1 Warning                                                                                                      ║
       ╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝

      at Context.it (tests\lib\formatters\table.js:122:20)

  4) formatter:table
       when passed a fatal error message
         should return a string in the correct format:

      AssertionError: expected '\nfoo.js\n\n║ \u001b[1mLine\u001b[22m     │ \u001b[1mColumn\u001b[22m   │ \u001b[1mType\u001b[22m     │ \u001b[1mMessage\u001b[22m
                                     │ \u001b[1mRule ID\u001b[22m              ║\n╟──────────┼──────────┼──────────┼────────────────────────────────────────────────────────┼──────────────────────╢\n║ 5        │ 10       │ \u001b[31merror\u001b[39m    │ Unexpected foo.                                        │ foo                  ║\n\n╔════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗\n║ \u001b[31m1 Error\u001b[39m
                                                                  ║\n╟────────────────────────────────────────────────────────────────────────────────────────────────────────────────╢\n║ \u001b[33m0 Warnings\u001b[39m                                                                                                     ║\n╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝\n' to equal '\nfoo.js\n\n║ Line     │ Column   │ Type     │ Message
                                │ Rule ID              ║\n╟──────────┼──────────┼──────────┼────────────────────────────────────────────────────────┼──────────────────────╢\n║ 5        │ 10       │ error    │ Unexpected foo.                                        │ foo                  ║\n\n╔════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗\n║ 1 Error
  ║\n╟────────────────────────────────────────────────────────────────────────────────────────────────────────────────╢\n║ 0 Warnings
                                                             ║\n╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝\n'
      + expected - actual


       foo.js

      -║ Line     │ Column   │ Type     │ Message                                                │ Rule ID              ║
      +║ Line     │ Column   │ Type     │ Message                                                │ Rule ID              ║
       ╟──────────┼──────────┼──────────┼────────────────────────────────────────────────────────┼──────────────────────╢
      -║ 5        │ 10       │ error    │ Unexpected foo.                                        │ foo                  ║
      +║ 5        │ 10       │ error    │ Unexpected foo.                                        │ foo                  ║

       ╔════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
      -║ 1 Error                                                                                                        ║
      +║ 1 Error                                                                                                        ║
       ╟────────────────────────────────────────────────────────────────────────────────────────────────────────────────╢
      -║ 0 Warnings                                                                                                     ║
      +║ 0 Warnings                                                                                                     ║
       ╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝

      at Context.it (tests\lib\formatters\table.js:163:20)

  5) formatter:table
       when passed multiple messages
         should return a string with multiple entries:

      AssertionError: expected '\nfoo.js\n\n║ \u001b[1mLine\u001b[22m     │ \u001b[1mColumn\u001b[22m   │ \u001b[1mType\u001b[22m     │ \u001b[1mMessage\u001b[22m
                                     │ \u001b[1mRule ID\u001b[22m              ║\n╟──────────┼──────────┼──────────┼────────────────────────────────────────────────────────┼──────────────────────╢\n║ 5        │ 10       │ \u001b[31merror\u001b[39m    │ Unexpected foo.                                        │ foo                  ║\n║ 6        │ 11       │ \u001b[33mwarning\u001b[39m  │ Unexpected bar.                                        │ bar                  ║\n\n╔════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗\n║ \u001b[31m1 Error\u001b[39m
                             ║\n╟────────────────────────────────────────────────────────────────────────────────────────────────────────────────╢\n║ \u001b[33m1 Warning\u001b[39m                                                                                                      ║\n╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝\n' to equal '\nfoo.js\n\n║ Line     │ Column   │ Type     │ Message                                                │ Rule ID              ║\n╟──────────┼──────────┼──────────┼────────────────────────────────────────────────────────┼──────────────────────╢\n║ 5        │ 10       │ error    │ Unexpected foo.                                        │ foo                  ║\n║ 6        │ 11       │ warning  │ Unexpected bar.                                        │ bar                  ║\n\n╔════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗\n║ 1 Error
                                                                                 ║\n╟────────────────────────────────────────────────────────────────────────────────────────────────────────────────╢\n║ 1 Warning                                                                                                      ║\n╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝\n'
      + expected - actual


       foo.js

      -║ Line     │ Column   │ Type     │ Message                                                │ Rule ID              ║
      +║ Line     │ Column   │ Type     │ Message                                                │ Rule ID              ║
       ╟──────────┼──────────┼──────────┼────────────────────────────────────────────────────────┼──────────────────────╢
      -║ 5        │ 10       │ error    │ Unexpected foo.                                        │ foo                  ║
      -║ 6        │ 11       │ warning  │ Unexpected bar.                                        │ bar                  ║
      +║ 5        │ 10       │ error    │ Unexpected foo.                                        │ foo                  ║
      +║ 6        │ 11       │ warning  │ Unexpected bar.                                        │ bar                  ║

       ╔════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
      -║ 1 Error                                                                                                        ║
      +║ 1 Error                                                                                                        ║
       ╟────────────────────────────────────────────────────────────────────────────────────────────────────────────────╢
      -║ 1 Warning                                                                                                      ║
      +║ 1 Warning                                                                                                      ║
       ╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝

      at Context.it (tests\lib\formatters\table.js:212:20)

  6) formatter:table
       when passed multiple files with 1 message each
         should return a string with multiple entries:

      AssertionError: expected '\nfoo.js\n\n║ \u001b[1mLine\u001b[22m     │ \u001b[1mColumn\u001b[22m   │ \u001b[1mType\u001b[22m     │ \u001b[1mMessage\u001b[22m
                                     │ \u001b[1mRule ID\u001b[22m              ║\n╟──────────┼──────────┼──────────┼────────────────────────────────────────────────────────┼──────────────────────╢\n║ 5        │ 10       │ \u001b[31merror\u001b[39m    │ Unexpected foo.                                        │ foo                  ║\n\nbar.js\n\n║ \u001b[1mLine\u001b[22m     │ \u001b[1mColumn\u001b[22m   │ \u001b[1mType\u001b[22m     │ \u001b[1mMessage\u001b[22m                                                │ \u001b[1mRule ID\u001b[22m              ║\n╟──────────┼──────────┼──────────┼────────────────────────────────────────────────────────┼──────────────────────╢\n║ 6        │ 11
   │ \u001b[33mwarning\u001b[39m  │ Unexpected bar.                                        │ bar                  ║\n\n╔════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗\n║ \u001b[31m1 Error\u001b[39m
                      ║\n╟────────────────────────────────────────────────────────────────────────────────────────────────────────────────╢\n║ \u001b[33m1 Warning\u001b[39m
                                                                                                     ║\n╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝\n' to equal '\nfoo.js\n\n║ Line     │ Column   │ Type     │ Message                                                │ Rule ID
           ║\n╟──────────┼──────────┼──────────┼────────────────────────────────────────────────────────┼──────────────────────╢\n║ 5        │ 10       │ error    │ Unexpected foo.                                        │ foo                  ║\n\nbar.js\n\n║ Line     │ Column   │ Type     │ Message
  │ Rule ID              ║\n╟──────────┼──────────┼──────────┼────────────────────────────────────────────────────────┼──────────────────────╢\n║ 6        │ 11       │ warning  │ Unexpected bar.                                        │ bar                  ║\n\n╔════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗\n║ 1 Error                                                                                                        ║\n╟────────────────────────────────────────────────────────────────────────────────────────────────────────────────╢\n║ 1 Warning
                               ║\n╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝\n'
      + expected - actual


       foo.js

      -║ Line     │ Column   │ Type     │ Message                                                │ Rule ID              ║
      +║ Line     │ Column   │ Type     │ Message                                                │ Rule ID              ║
       ╟──────────┼──────────┼──────────┼────────────────────────────────────────────────────────┼──────────────────────╢
      -║ 5        │ 10       │ error    │ Unexpected foo.                                        │ foo                  ║
      +║ 5        │ 10       │ error    │ Unexpected foo.                                        │ foo                  ║

       bar.js

      -║ Line     │ Column   │ Type     │ Message                                                │ Rule ID              ║
      +║ Line     │ Column   │ Type     │ Message                                                │ Rule ID              ║
       ╟──────────┼──────────┼──────────┼────────────────────────────────────────────────────────┼──────────────────────╢
      -║ 6        │ 11       │ warning  │ Unexpected bar.                                        │ bar                  ║
      +║ 6        │ 11       │ warning  │ Unexpected bar.                                        │ bar                  ║

       ╔════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
      -║ 1 Error                                                                                                        ║
      +║ 1 Error                                                                                                        ║
       ╟────────────────────────────────────────────────────────────────────────────────────────────────────────────────╢
      -║ 1 Warning                                                                                                      ║
      +║ 1 Warning                                                                                                      ║
       ╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝

      at Context.it (tests\lib\formatters\table.js:272:20)

  7) formatter:table
       when passed one file not found message
         should return a string without line and column (0, 0):

      AssertionError: expected '\nfoo.js\n\n║ \u001b[1mLine\u001b[22m     │ \u001b[1mColumn\u001b[22m   │ \u001b[1mType\u001b[22m     │ \u001b[1mMessage\u001b[22m
                                     │ \u001b[1mRule ID\u001b[22m              ║\n╟──────────┼──────────┼──────────┼────────────────────────────────────────────────────────┼──────────────────────╢\n║ 0        │ 0        │ \u001b[31merror\u001b[39m    │ Couldn\'t find foo.js.                                  │                      ║\n\n╔════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗\n║ \u001b[31m1 Error\u001b[39m
                                                                   ║\n╟────────────────────────────────────────────────────────────────────────────────────────────────────────────────╢\n║ \u001b[33m0 Warnings\u001b[39m                                                                                                     ║\n╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝\n' to equal '\nfoo.js\n\n║ Line     │ Column   │ Type     │ Message
                                 │ Rule ID              ║\n╟──────────┼──────────┼──────────┼────────────────────────────────────────────────────────┼──────────────────────╢\n║ 0        │ 0        │ error    │ Couldn\'t find foo.js.                                  │                      ║\n\n╔════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗\n║ 1 Error
    ║\n╟────────────────────────────────────────────────────────────────────────────────────────────────────────────────╢\n║ 0 Warnings
                                                               ║\n╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝\n'
      + expected - actual


       foo.js

      -║ Line     │ Column   │ Type     │ Message                                                │ Rule ID              ║
      +║ Line     │ Column   │ Type     │ Message                                                │ Rule ID              ║
       ╟──────────┼──────────┼──────────┼────────────────────────────────────────────────────────┼──────────────────────╢
      -║ 0        │ 0        │ error    │ Couldn't find foo.js.                                  │                      ║
      +║ 0        │ 0        │ error    │ Couldn't find foo.js.                                  │                      ║

       ╔════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
      -║ 1 Error                                                                                                        ║
      +║ 1 Error                                                                                                        ║
       ╟────────────────────────────────────────────────────────────────────────────────────────────────────────────────╢
      -║ 0 Warnings                                                                                                     ║
      +║ 0 Warnings                                                                                                     ║
       ╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝

      at Context.it (tests\lib\formatters\table.js:310:20)

Therefore, this PR fixes the problem. The before-all hook disables coloring and after-all hook restore it.

Is there anything you'd like reviewers to focus on?

Nothing in particular.

If standalone mocha command ran it, coloring caused to fail the tests.
@mysticatea mysticatea added infrastructure Relates to the tools used in the ESLint development process chore This change is not user-facing labels Mar 21, 2019
Copy link
Member

@not-an-aardvark not-an-aardvark left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@aladdin-add aladdin-add merged commit f16af43 into master Mar 22, 2019
@aladdin-add aladdin-add deleted the fix-formatter-table-test branch March 22, 2019 12:19
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Sep 19, 2019
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Sep 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion chore This change is not user-facing infrastructure Relates to the tools used in the ESLint development process
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants