Git Product home page Git Product logo

Comments (5)

lirantal avatar lirantal commented on May 26, 2024

Oh I see. That's a good catch @arszh
Not sure how I feel about that gist workaround, doesn't seem friendly. What if we just refactor the test a bit so that the expect is simply not inside a try/catch?

from typeform-export-excel.

arszh avatar arszh commented on May 26, 2024

We can declare actual and expected variables before try/catch and move down expect(expected.size).toEqual(actual.size) under try/catch, but I think it is not good.

In my opinion, maybe I wrong, we can delete the try/catch altogether because:

  1. It prevents find errors and situations where exceptions are raised.
  2. Test doesn't check receiving certain exceptions.
  3. 'Catch' doesn't improve information from caught exception to output it.

If important to remove created file after this test:

  1. It will be deleted anyway when developer fix fail and the test is passed.
  2. Can use afterAll() to remove all created excel files after all tests.

from typeform-export-excel.

lirantal avatar lirantal commented on May 26, 2024

this is the test we're referring to, right?

    try {
      // eslint-disable-next-line
      const actual = fs.statSync(path.resolve('./__tests__/Fixtures/sample.xlsx'))
      // eslint-disable-next-line
      const expected = fs.statSync(path.resolve(testOutputFilename))

      expect(expected.size).toEqual(actual.size)
    } catch (e) {
    } finally {
      // eslint-disable-next-line
      fs.unlinkSync(testOutputFilename)
    }

in which case, the expectation is within a try/catch only for the sake of cleaning-up. In this case, how about we simply clean up in a Jest's afterAll() hook? Surely it's not as clean as with doing this within every test, but for the sake of this small lib seems not far fetched.

Looks like you are suggesting the same so 👍 from me and I'm happy to merge a PR if you have a bit of time to send it over.

from typeform-export-excel.

lirantal avatar lirantal commented on May 26, 2024

fixed in #18

from typeform-export-excel.

Harshu53 avatar Harshu53 commented on May 26, 2024

@arszh @lirantal Can you guys please suggest what should be fixed for below case, It is always passing :

test("test", () => {
  try {
    expect(true).toBe(false);
  } catch (err) {
    console.log(err);
  }
});

from typeform-export-excel.

Related Issues (4)

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.