TestUtils.getControllerOf Returns TypeError

#7 · closed · 2 comments

View on GitHub ↗

jminnihan

When writing a Jest test for a App.jsx based AppController.js function using the TestUtils.getControllerOf(component.instance()) statement, I receive the following error: TypeError: cannot read property '__reactViewControllersIdForTesting' of null. ` describe("App Controller", () => { beforeEach(() => { TestUtils.init(); }); afterEach(() => { TestUtils.clean(); }); it("should login the user via the login function", () => { const component = mount(<App />); const controller = TestUtils.getControllerOf(component.instance()); const user = controller.login('[email protected]', 'myP@sswd'); expect(user).toEqual({ email: "[email protected]", username: 'user' }); });` React: 16.8.6 Controllerim: 1.62.0 Jest: 24.7.1

Comments

Niryo

@jminnihan, What lib are you using for mounting? I just tried it using enzyme and it works. do you have a repo for me to clone?

Niryo

I am closing this issue because I cannot reproduce it. Please feel free to open it if you think it's still relevant