Closed wictorwilen closed 1 year ago
Hello wictorwilen, 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 🙌
We are facing the same issue with any Microsoft Graph Toolkit component used within our React application. @sebastienlevert Do you have any workaround to be able to run tests with Jest until it's resolved in the tookit sdk ?
We are looking into this issue but don't have a solution for now. Adding @Mnickii that has been looking into it in the past.
Mocking the module until the issue is resolved could be a workaround for other tests to pass. @Mimetis
jest.mock('@microsoft/mgt-react', () => ({
__esModule: true,
default: 'mocked',
MgtPersonCard: jest.fn(),
Person: jest.fn(),
PersonCardInteraction: jest.fn(),
}));
Describe the bug When running tests on MGT, for instance using (the very common) Jest framework, all test suites including MGT components fails due to a transformation error - due to MGT being ES6/ESM only. Jest only ships with experimental support for ESM as of now.
This is the shown error:
Same or similar issues has already been reported (and closed due to no response, most likely because folks just skipped testing solutions with MGT). See #596, #1320, #110.
To Reproduce Steps to reproduce the behavior:
npx create-react-app mgt-test
cd mgt-test
npm install @microsoft/mgt-react --save
App.js
so it looks as follows:Expected behavior Expectations is for the tests to run without any transformation errors (
Jest encountered an unexpected token
)Recommendation I would suggest that MGT either ships both a
cjs
andes6
version (which would be great for projects that not yet have fully embracedesm
) and/or documentation on how to set up the test configuration/transformation withjest
andts-jest
.Environment (please complete the following information):