-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to use OfficeMockObject in jsdom test environment #653
Comments
I'm not sure if this is a problem with the |
TL;DR: turning off usage-data collection with the following command circumvents this issue:
Hi @igor-ribeiiro, I don't think it is a configuration issue. Putting the comment /**
* @jest-environment jsdom
*/ at the top of a test file has the same effect, as configuring the I did some further research towards the cause of this error. throw new Error(err); I replaced it with: throw err; This revealed two more lines in the stacktrace:
Looking at the code,
When running the test again afterwards, I received different errors which I was able to resolve by tuning the jest config. I guess you can close this issue, but I propose following options to prevent people from running into this issue in the future:
|
We will keep the issue open until this is fixed. Thanks for providing a workaround for now, hopefully, it will work for others until fixed. |
Any updates on a fix for this? Unfortunately, @mspiess' workaround didn't work for me. I'm able to use office-addin-mock with jest v27, but not with v28 or v29 (and those newer versions of jest are necessary for other upgrades we'd like to make). |
@carlhauck it sounds like your problem is different. Can you enter a new issue with the errors you get when using v28 or v29? |
I have upgraded yesterday from jest 27 to 29 with similar results: `
And I found out that latest version of Jest avtivates ESM mode by looking type property at the package.json file (Jest docs ESM ) |
We also encountered the similar issue as above. V29 is not compatible. And |
I was also able to reproduce this issue with jest v29. I was able to get a fix working (Thanks @mspiess). I'm running a JS project and not typescript so I modified the Jest config changes a little bit and only seemed to need:
To get it working. |
Any updates on this ? I have tried the workarounds suggested in the comments however I still hit this issue of:
I am using jest v29 and |
Prerequisites
Expected behavior
The jest test runner runs the tests with jsdom environment without error while making use of "office-addin-mock".
Current behavior
The test fails to run because "office-addin-mock" seems to expect a Node environment (see Failure Logs below).
Steps to Reproduce
Run the following test file:
Context
Packages installed in addition to the office-addin-react starter:
jest.config.js
:Test script:
jest
Failure Logs
The text was updated successfully, but these errors were encountered: