Giter Club home page Giter Club logo

Comments (5)

kristerkari avatar kristerkari commented on May 27, 2024

Sorry, I don't quite understand what you mean here. There is already documentation for adding a mock file to your project, is that not enough?

from react-native-svg-transformer.

kristerkari avatar kristerkari commented on May 27, 2024

I'm closing this as inactive, let's re-open if something new comes up.

from react-native-svg-transformer.

JSanchezIO avatar JSanchezIO commented on May 27, 2024

I ran into an error that I believe the original author was trying to convey. My project uses Typescript and Jest. Using the documentation provided on mocking this library doesn't work. However, using the author's suggestion the mock works.

from react-native-svg-transformer.

jeandiego avatar jeandiego commented on May 27, 2024

Just to contribute to anyone trying to use the .js setup in a TypeScript project, follow @davidsonsns's suggestion and everything will work.

I believe that could be helpful to add documentation to create a svgMock file for typescript project. Maybe people want to add just .ts files in your folder structure.

To fix on my current project I did it:

const exported = 'SvgMock';
export const ReactComponent = exported;
export default exported;

If sounds good I can contribute to the project with this adding it on the documentation.

from react-native-svg-transformer.

davidsonsns avatar davidsonsns commented on May 27, 2024

tbh i don't remember exactly the issue (pls lemme know if im overcomplicating things @jeandiego - btw mentioning you because you were the most recent person to comment).

but the issue is: if a project only include ts files (or at least try to do so), most of the time maintainers will try to create __mocks__/svgMock.ts (with .ts) rather than __mocks__/svgMock.js (with .js).

so we could introduce something like below to the README:

// __mocks__/svgMock.js
module.exports = "SvgMock";
module.exports.ReactComponent = "SvgMock";

// TS version
// __mocks__/svgMock.ts
const exported = 'SvgMock';
export const ReactComponent = exported;
export default exported;

off-topic: damn! my english was really bad back in 2019 (It's still not perfect, but it's gotten a little better). my bad @kristerkari

from react-native-svg-transformer.

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.