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

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

Merged
merged 2 commits into from Sep 13, 2018

Conversation

Projects
None yet
5 participants
@j-f1
Copy link
Member

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

10 checks passed

ci/circleci: build_prod Your tests passed on CircleCI!
Details
ci/circleci: checkout_code Your tests passed on CircleCI!
Details
ci/circleci: test_prod_node4 Your tests passed on CircleCI!
Details
ci/circleci: test_prod_node9 Your tests passed on CircleCI!
Details
ci/circleci: test_prod_standalone Your tests passed on CircleCI!
Details
codecov/patch 100% of diff hit (target 80%)
Details
codecov/project 96.25% (+<.01%) compared to b020a56
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
deploy/netlify Deploy preview ready!
Details

@j-f1 j-f1 deleted the j-f1:it-timeout branch Sep 13, 2018

@ikatyang ikatyang added this to the 1.15 milestone Oct 25, 2018

@niieani

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Member Author

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 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.
You can’t perform that action at this time.