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
Firestore incompatible with Create React App / Jest / JSDOM #344
Comments
I ran into a series of issues trying to get CRA/Jests tests working with |
I've raised a bunch of issues and come to the conclusion that at the moment it's not really possible/simple at the moment unfortunately. I'm currently in the process of coming up with add decent mocking solution. |
I'm running tests with the above configuration without issues. Here's what i do package.json: (ignore craco, that's just for less support, you can use react-scripts here)
Then, the customTestEnvironment.js /* eslint-disable @typescript-eslint/no-empty-function */
// __test-utils__/custom-jest-environment.js
// Stolen from: https://github.com/ipfs/jest-environment-aegir/blob/master/src/index.js
// Overcomes error from jest internals.. this thing: https://github.com/facebook/jest/issues/6248
'use strict';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const NodeEnvironment = require('jest-environment-jsdom');
class MyEnvironment extends NodeEnvironment {
constructor(config) {
super(
Object.assign({}, config, {
globals: Object.assign({}, config.globals, {
Uint32Array: Uint32Array,
Uint8Array: Uint8Array,
ArrayBuffer: ArrayBuffer,
}),
}),
);
}
async setup() {}
async teardown() {}
}
module.exports = MyEnvironment;
|
Hi @Mattinton, now that firebase/firebase-js-sdk#4552 is fixed, is this still an issue? |
Hey @jhuleatt, things are working now with the fix from @dahmc. Maybe this should be documented somewhere or raised as a new issue as it seems to come and go.. Either way I think you can probably close this? |
Thanks for confirming it is working now. Hopefully it won't pop up again now that the root issue, grpc/grpc-node#1708, is now resolved. |
Version info
React: 17
Firebase: 8.2.10
ReactFire: 3.0.0-rc.0
Test case
Steps to reproduce
Expected behavior
Test should pass
Actual behavior
I've also raised issues elsewhere. I believe the problem is that Jest is loading Node dependencies and not the browser ones. I would be happy to find a workaround that lets me keep using create-react-app if the issues cant be fixed.
firebase/firebase-js-sdk#4552
facebook/create-react-app#10626
The text was updated successfully, but these errors were encountered: