In attempting to switch from react-appinsights to application-insights-react-js, many of my Jest tests starting failing with this error:
● Test suite failed to run
Cannot find module './cjs/react.development.js' from 'applicationinsights-react-js.js'
This is easily reproducible by cloning the demo app, then attempting to run tests. You may want to consider an Azure Pipelines build to the demo app to catch this kind of thing.
confirmed, simple swap from final RC to this release (with the minor breaking config changes) blows up tests while the runtime code seems to work fine. please assist. with RC6 i had a full suite of passing tests.
Interesting. I believe I had the same issue with RC5, but thought it would be fixed before the final RC, so I just waited to make the switch.
Interesting. I believe I had the same issue with RC5, but thought it would be fixed before the final RC, so I just waited to make the switch.
fwiw, the 'final' RC candidate i was using was from this repo https://github.com/Azure/react-appinsights because i was unaware of the repo relocation. possible there were minor variances between the new repo location and the old, i was unaware this new repo existed (if it did indeed exist before the final release). so it's possible we were using different RCs, although i'm sure my was listed in package.json as RC6.
We are working on fixing this issue, like @csuich2 mentioned we found it while updating the sample app and we believe is specific to Create React App Jest configuration, let me know if you see this error in different environments.
I also encounter this when using "next": "8.1.0", when starting the development server via next (note that you need to visit the URL first for it to compile)
We are working on fixing this issue, like @csuich2 mentioned we found it while updating the sample app and we believe is specific to Create React App Jest configuration, let me know if you see this error in different environments.
thanks for the quick follow-up, fwiw, i can confirm i used create-react-app to bootstrap my initial application.
until gets fixed, you can mock it:
jest.mock('@microsoft/applicationinsights-react-js', () => ({ ReactPlugin: jest.fn() }));
@hectorhdzg asked:
let me know if you see this error in different environments.
Failing for me now... tests were working for my app (_SharePoint Framework + React... not created with Create React App jest config_) until I added the React plugin for AI so removing it for now.
@andrewconnell The fix for this just landed in the latest release. Can you update your web SDK and React plugin to latest version and verify that it is working now?
latest React plugin = 2.0.2
latest Web SDK = 2.0.1
It's now working... thanks @markwolff ! Can't close the issue as I'm not the OP.
@csuich2 going to close this for now. Reopen if it is not working for you after updating the react plugin to 2.0.2
The fix for this just landed in the latest release. Can you update your web SDK and React plugin to latest version and verify that it is working now?
latest React plugin = 2.0.2
latest Web SDK = 2.0.1
also confirm it works with the version specified, sorry it took so long for me to get back to this, business priorities pulled me away from the project for a couple week. thanks for the quick fix. 👍
Most helpful comment
until gets fixed, you can mock it:
jest.mock('@microsoft/applicationinsights-react-js', () => ({ ReactPlugin: jest.fn() }));