Closed elav000 closed 10 months ago
Hello elav000, thank you for opening an issue with us!
I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌
Hi @elav000, thanks for submitting this. As you have seen, our testing setup in the toolkit leaves some to be desired... I agree that we should offer some testing examples :)
There are some jest tests for Mgt, but they are very stale. We should see if we can get jest working in the main project, as well as in a sample app 👍
Thanks @shweaver-MSFT! It's greatly appreciated.
Also experiencing this issue in my jest tests. How can I test my code while also including this package?
TypeError: Cannot read property 'define' of undefined
2 | import { AuthContext as AuthContextData } from './AuthContext';
3 |
> 4 | import { Providers, ProviderState } from '@microsoft/mgt-element';
| ^
5 | import { Msal2Provider, Msal2Config, Msal2PublicClientApplicationConfig } from '@microsoft/mgt-msal2-provider';
6 |
Adding @gavinbarron around this topic. Is this doable and is easier with the new v3 release?
I think that it's about the same level of complexity between v2 and v3 TBH, that said, as we have some working Jest tests in v3 for mgt-components it should be reasonably straightforward to port that approach into the react-contoso sample app
At the moment, this is not something we're likely to prioritize. That being said, the Graph Toolkit is an open source project and we'll be happy to support and review if you want to contribute to its codebase! In the meantime, we will be closing this issue. Thanks!
Describe the bug While the example itself works just fine, if you try to add a test that pulls in any resource from @microsoft/mgt it will fail. I am trying to setup something similar in a create react app and am having some difficulty figuring out how to get jest setup properly with create-react-app and @microsoft/mgt.
It is probably related to issue 110, but having a documented set of guidelines for consumers of @microsoft/mgt inside the project would be helpful. Otherwise, each project will need to go figure out how to integrate the library into their own package and testing framework.
To Reproduce Steps to reproduce the behavior:
yarn
src\__tests__
called index.test.js with the following contents:it('PersonViewType oneline should be three', () => { expect(PersonViewType.oneline).toEqual(3); });
Environment (please complete the following information):