Jasmine to the back

I have a React component class with several methods -

var testClass = React.createClass({ testMethod: function(){//do something } componentDidMount: function(){ this.testMethod(); } render: function() { ... } }); 

I am trying to add unit test using jasmine

 import TestClass from './testClass'; describe('test functions', () => { 'use strict'; spyOn(TestClass.prototype, 'testMethod'); it('test calls testMethod', () => { component = TestUtils.renderIntoDocument(<TestClass />); expect(TestClass.prototype.testMethod).toHaveBeenCalled(); }); 

I can see in the debugger that testMethod does indeed invoke the call, but the jasmine reports are "The expected test method spy testMethod that was called."

+5
source share

Source: https://habr.com/ru/post/1234218/


All Articles