实例方法异常:未定义事件

时间:2019-06-03 13:18:38

标签: jestjs jest-fetch-mock

Jest的新手,试图编写一个基本的测试用例来检查Jest中的Dropdown功能。

我尝试了以下代码:

test( "update state with dropdown", async () => {

    let wrapper = mount( <MemoryRouter initialEntries={[ “/workflow/new" ]}><Workflow/></MemoryRouter> );

    expect.assertions( 7 );

    // Mock validation API calls
    let apiWorkflowPromise = Promise.resolve( apiWorkflowResult );
    get.mockImplementation( () => apiWorkflowPromise );

    // ACT
    let instance = wrapper.find( “Workflow” ).instance();
    instance.handleWorkflowDropDownChange( { target: { value: “NewZealand” } } );
    await expect( apiWorkflowPromise ).resolves.toBeDefined();

    // ASSERT
    let selectedDiagnosticWorkflow = instance.state.selectedWorkflow;
    let supportedParameters = instance.state.workflow.supportedParameters;
    expect( selectedWorkflow ).toEqual( “NewZealand” );

 } );

出现以下错误:

  

ReferenceError:未定义事件   在Workflow.handleWorkflowDropDownChange

0 个答案:

没有答案