Giter Site home page Giter Site logo

Comments (4)

benkimpel avatar benkimpel commented on May 24, 2024 2

Hey @ryanwilsonperkin and @hockeybuggy!

It's funny, but the expect behaviour we implemented is exactly what I needed for my team, but it's good to see some feedback on it in practice from people that I do not boss around. Let me share the thinking that went into it and then let me know if that changes any minds. ;^) It's ok if it doesn't, formatting is subjective and personal.

The goal was to support as best we can the Arrange Act Assert pattern of writing tests, wherein the blank line is an important part of delimiting the steps. This plugin can't get us all the way there by any means, but it can handle maybe 90% of the separation between act and assert. There are other ESLint rules (padding-line-between-statements which this rule is based on) that can add a padding line between variable declarations at the top of a scope so we can get closer still... but a full programmatic implementation of Arrange Act Assert is probably not possible. Still, 90% reliable separation between Act and Assert seemed like a win for me.

So that was the goal, but as noted above formatting is subjective. For an opinionated formatting plugin like this one the best we can do is pick something that most people like as the default and enforce it while providing a few escape hatches along the way. So long story short... It's all good with me to take it out of recommended if people feel strongly about it. I'd vote for removing it from recommended over making it a configuration option of some kind.

@ryanwilsonperkin as a workaround for now you'll want to list the rules individually, excluding the expect of course.

from eslint-plugin-jest-formatting.

hockeybuggy avatar hockeybuggy commented on May 24, 2024

I am a big fan of using whitespace as a way to communicate different sections of the tests. On my best days I prefer:

it("should do that thing", () => {
// [setup]

// [preconditions]

// exercise subject of test

// postconditions

// [cleanup]
})

The think that I don't like with this rule is that it's assuming that the only thing in the preconditions and postconditions sections are expect calls. As shown in @ryanwilsonperkin's examples it's sometimes prudent to alias something by assigning to a variable.

I do think that this rule may be something that some people would like to have access to, but think that it should be excluded from the recommend preset.

from eslint-plugin-jest-formatting.

dangreenisrael avatar dangreenisrael commented on May 24, 2024

@benkimpel thoughts?

from eslint-plugin-jest-formatting.

dangreenisrael avatar dangreenisrael commented on May 24, 2024

I'm +1 to taking this our of the recommended config. Especially since @benkimpel is working on an 'all' rule.

from eslint-plugin-jest-formatting.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.