Coder Social home page Coder Social logo

Comments (7)

skovhus avatar skovhus commented on June 12, 2024

@jwedel thanks for reporting this. And let me know if you are up for creating a PR fixing this.

from jest-codemods.

jwedel avatar jwedel commented on June 12, 2024

@skovhus I've created a PR with a failing test but I have no idea how to fix this. I've looked at the jasmine-globals.ts but I can't figure out where to start...

from jest-codemods.

jwedel avatar jwedel commented on June 12, 2024

I figured out that it is possible to replace

focusMonitorMock.monitor.and.returnValue(of()); 

by

focusMonitorMock.monitor.mockReturnValue(of()); 

I've changed the test and finally figured out how to write transformation that makes the tests green.

However, I have to say that the implementation is very hard to read and understand, especially the reverse tree is messing with my mind. Moreover, IMO it's pretty bad that the actual test() call is wrapped in a reusable function. That makes debugging and running of individual tests pretty hard.

from jest-codemods.

skovhus avatar skovhus commented on June 12, 2024

IMO it's pretty bad that the actual test() call is wrapped in a reusable function. That makes debugging and running of individual tests pretty hard.

I see what you are saying. For running individual tests you can run yarn test:watch (Jest in watch mode) and filter the tests by test name. Example:

  • yarn test:watch
  • press w for menu
  • press t for test name filtering
  • type maps expect within matchers and enter

Or you can just watch failed tests or test that are modified.

from jest-codemods.

jwedel avatar jwedel commented on June 12, 2024

@skovhus Yes, that can be done. However, I am using my IDEs functionality (IntellIJ in this case) to run individual tests. But that only works if there are actual tests that can be discovered. Moreover, I don't see any need to handle it the way it is right now. I would suggest to do change the structure like that:

test('My name', () => {
   assertTransformation('input', 'output')
})

function assertTransformation(source, expectedOutput) {
    const result = wrappedPlugin(source)
    expect(result).toBe(expectedOutput)
}

That still allows using jest functionalility plus using an IDE to run tests.

from jest-codemods.

skovhus avatar skovhus commented on June 12, 2024

I would suggest to do change the structure like that:

That is a great idea. Let me know if you are up for fixing it. :)

from jest-codemods.

jwedel avatar jwedel commented on June 12, 2024

I would suggest to do change the structure like that:

That is a great idea. Let me know if you are up for fixing it. :)

Done with #202 thanks to heavy use of multi-cursor actions :)

from jest-codemods.

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.