Giter Site home page Giter Site logo

Comments (7)

andrewconnell avatar andrewconnell commented on July 19, 2024 2

Thanks... I can repo. Investigating...

from jest-preset-spfx-react16.

andrewconnell avatar andrewconnell commented on July 19, 2024

Update - I understand why this is happening, but I can't figure out how to fix it for a bigger set of circumstances.

It's easy to fix for just the one library you're using, but this will quickly turn into a +1 issue when someone uses another library, so I'm looking for a more dynamic solution... this is affecting all three of my presets...

Still working...

from jest-preset-spfx-react16.

petecuttriss avatar petecuttriss commented on July 19, 2024

Understood. Have a merry Christmas Andrew! Thanks again for your all help.

from jest-preset-spfx-react16.

andrewconnell avatar andrewconnell commented on July 19, 2024

Something occurred to me: What you're trying to do won't give you desirable results. You're trying to use the Environment & EnvironmentType objects that won't yield desirable results outside of a SharePoint context.

You should be able to just add the following in your spec file to tell Jest to mock those two objects without any changes to the jest config file:

jest.mock('@microsoft/sp-core-library/', () => {
  return {
    'Environment': {},
    'EnvironmentType': {},
  };
});

I'm going to close this issue for now, but still working on a more robust solution in the case where it appears as an issue in other projects.

from jest-preset-spfx-react16.

taranxd avatar taranxd commented on July 19, 2024

I am facing the similar issue and writing the above code didn't fix the issue :(

from jest-preset-spfx-react16.

andrewconnell avatar andrewconnell commented on July 19, 2024

@taranxd please open a new issue with more details to better track the issue.

I became aware these presets are not working with the latest SPFx and need to investigate the root cause. Learned about the issue this week so will look into it shortly...

from jest-preset-spfx-react16.

jmunozcastro avatar jmunozcastro commented on July 19, 2024

Hello @andrewconnell, I am working implementing jest in some SPFx projects and I get the same error that explain @petecuttriss, the difference is that I am working with SPFx Framework v1.11 Do you have found another solution @andrewconnell or @petecuttriss? I appreciate so much the help ;)

from jest-preset-spfx-react16.

Related Issues (11)

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.