Skip to content

Add support for timeouts passed as integers to test functions#5085

Merged
j-f1 merged 2 commits intoprettier:masterfrom
j-f1:it-timeout
Sep 13, 2018
Merged

Add support for timeouts passed as integers to test functions#5085
j-f1 merged 2 commits intoprettier:masterfrom
j-f1:it-timeout

Conversation

@j-f1
Copy link
Copy Markdown
Member

@j-f1 j-f1 commented Sep 12, 2018

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory)
  • I’ve read the contributing guidelines.

Fixes #5061

@j-f1 j-f1 merged commit 5972039 into prettier:master Sep 13, 2018
@j-f1 j-f1 deleted the it-timeout branch September 13, 2018 10:08
@ikatyang ikatyang added this to the 1.15 milestone Oct 25, 2018
@niieani
Copy link
Copy Markdown

niieani commented Nov 7, 2018

Why was this added? What's the reasoning? There's nothing meaningful in #5051. I much prefer the standard, consistent formatting to the new, custom formatting.

@duailibe
Copy link
Copy Markdown
Collaborator

duailibe commented Nov 7, 2018

@niieani to keep consistent with how we format other tests

Before

it('name of a test', () => {
  // code
});

it(
  'name of another test',
  () => {
    // code
  },
  200
);

Now

it('name of a test', () => {
  // code
});

it('name of another test', () => {
  // code
}, 200);

@niieani
Copy link
Copy Markdown

niieani commented Nov 7, 2018

Why do we format tests using a separate logic altogether?
I find default output much more readable. You can see at a glance which argument of the function is being passed into it. The new behavior has this odd trailing }, 200) is hard to read and looks really ugly.

I see this odd formatting logic only kicks in for it and test named functions. I think this is quite fragile, it means things like this will be "broken" too.

@j-f1
Copy link
Copy Markdown
Member Author

j-f1 commented Nov 7, 2018

@niieani IMO that conditional is bad practice — your tests should always be static. Both sides of the ternary will format properly:

Prettier pr-5366
Playground link

--parser babylon

Output:

it("name of another test", () => {
  // code
}, 200);
it.skip("name of another test", () => {
  // code
}, 200);

Also, people will typically have many tests, so it’s more important IMO to keep the test code unindented than to have the () => { section readable.

@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Feb 5, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Feb 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants