TypeError: Cannot read property 'only' of undefined - casl

I am trying to use React Testing Library for my React project but it errors when trying to mount a component that imports CreatCanBountTo with the error:
TypeError: Cannot read property 'only' of undefined
> 1 | const { createCanBoundTo } = require('#casl/react');
I assume that it's due to casl not being initialised before the test runs.
Thank you in advanced for your help.

Related

Uncaught Error: Invariant Violation: expected a string but got: undefined when importing motion from framer-motion

I understand that this error only occurs when there is something wrong with the import. However, I have double checked the import:
import { motion } from "framer-motion";
and it should be correct. The thing is, the import works on other components. Just this specific component that when I import framer-motion it gives out this error.
Github Repo to the code base. As you can see in the components folder, I have used many framer-motion imports and they all worked perfectly. The component which gives out this error is in MenuRight.js which is located in ./components/main/Nav/MenuRight.js. I'm confused on why this happens.

Store: TypeError: Cannot read properties of undefined (reading 'ids') at selectIds

What is causing the issue in the title. I am basically getting a typeError when I try to retrieve data in a feature store module.
The issue was that I configurated wrongly the reducers in the StoreModule.forRoot inside the app.module.ts (I had multiple reducers so it should be declared in an object)

ng build throwing [error] TypeError: Cannot read property 'toLowerCase' of undefined

I have this error TypeError: Cannot read property 'toLowerCase' of undefined
styles.2f06433e92600f91a077.css - Error: styles.2f06433e92600f91a077.css from Css Minimizer
TypeError: Cannot read property 'toLowerCase' of undefined
I'm using Angular 12 version.
This means that the object on which you are calling the method .toLowerCase is of type undefined. This can either be by design and you can just add a check before calling it:
if (str) str.toLowerCase()
Or if you didn't expect to have an undefined variable in that part of the code there is a mistake somewhere else, in that case I can't really help you.

Using firestore.Timestamp.now() in Angular unit test

I am developing an Angular application, with angularfire2 5.0.0-rc.10. I really hope I don't mess up any terms in the following, but here we go.
I have converted Date's, to the new firestore Timestamp type. This gives me a problem when writing tests. I can only do the following:
import { firestore } from 'firebase/app';
it ('should create', () => {
firestore.Timestamp.now();
});
If I initialize firebase in my TestBed module with:
AngularFireModule.initializeApp(environment.firebase),
Otherwise I get the error:
TypeError: Cannot read property 'Timestamp' of undefined
So my questions:
Is this intended behaviour?
Are you not supposed to be able to create a firstore Timestamp data type, outside of an firebase angular project?
Why is firestore undefined when imported without the initializeApp?
Thanks so much for your help.
I resolved it below
angular version is 11.1.2
import firebase from 'firebase/app';
import 'firebase/firestore';
import Timestamp = firebase.firestore.Timestamp;

Push command creating error: Cannot read property 'replace' of undefined

I've seen variations of this question in the context of everything from AngularJS to KendoGrid to BackboneJS but all the answers are related to those frameworks and none of them address this directly at a straight-up Firebase level. Since I'm not using any of those, the answers are not helpful to me.
I create the following ref:
var loginRef = new Firebase('https://f30s.firebaseio.com/Pablo/pages/login');
I try the following push:
loginRef.child('clientEvents').push( { Create_account : true } );
The push writes to Firebase in the proper directory structure, but console produces the error:
Uncaught TypeError: Cannot read property 'replace' of undefined
What am I doing wrong?

Resources