lundi 15 juin 2020

wrapper.find not able to find FormInput (ReactJs + Enzyme

I have a simple test case where i check if FormInput is present. I am getting below result in terminal

Expected length: 1
Received length: 0
Received object: {}

And here is the test case. I also did a wrapper.debug() to see what i am getting as wrapper.

it('renders FormInput component', () => {
      console.log(wrapper.debug())
      expect(wrapper.find(FormInput)).toHaveLength(1)
    })

Here is the result of the console.log. You can see FormInput is present in here but still the test case is failing. Any suggestions/ help is appreciated.

<MockStoreProvider digitalCoreState= coreState= appState= appReducer={[Function: appReducer]} dispatch={[Function: dispatch]}>
        <Provider store=>
          <Memo fieldId="ImRequired" getString={[Function: mockConstructor]} defaultMemo="memo" memoFieldValidate={[Function: mockConstructor]} defaultMemoValidate={[Function: mockConstructor]} isConfirm={false}>
            <WithLayout className="memo">
              <WithSpace className="memo" style=>
                <Block className="memo" style= el="div">
                  <div className="memo" style=>
                    <FormField fieldId="ImRequired">
                      <Connect(Connect(WithFormContext))>
                        <Connect(WithFormContext) useWFFonts={false} dispatch={[Function: dispatch]}>
                          <WithFormContext useWFFonts={false} dispatch={[Function: dispatch]} strings= getString={[Function: getString]}>
                            <WithFormElementId formId={[undefined]} fieldId="ImRequired" fieldKey="undefined-ImRequired" useWFFonts={false} dispatch={[Function: dispatch]} strings= getString={[Function: getString]}>
                              <Connect(FormFieldLabel) formId={[undefined]} fieldId="ImRequired" fieldKey="undefined-ImRequired" useWFFonts={false} dispatch={[Function: dispatch]} strings= getString={[Function: getString]} formElementId="A0000001">
                                <FormFieldLabel formId={[undefined]} fieldId="ImRequired" fieldKey="undefined-ImRequired" useWFFonts={false} dispatch={[Function: dispatch]} strings= getString={[Function: getString]} formElementId="A0000001" fieldErrors= addLabel={[Function: addLabel]} removeLabel={[Function: removeLabel]} el="label">
                                  <WithLayout el="label" layout={true} horizontal={true} center={true} className="label" id="A0000001" htmlFor="ImRequired" data-en="label-undefined-ImRequired">
                                    <WithSpace el="label" className="label" id="A0000001" htmlFor="ImRequired" data-en="label-undefined-ImRequired" style=>
                                      <Block el="label" className="label" id="A0000001" htmlFor="ImRequired" data-en="label-undefined-ImRequired" style=>
                                        <label className="label" id="A0000001" htmlFor="ImRequired" data-en="label-undefined-ImRequired" style=>
                                          <WithLayout>
                                            <WithSpace style=>
                                              <Block style= el="div">
                                                <div style=>
                                                  <div className="memoLabel">
                                                    <Connect(Translatable) id="memoOrInvoiceNumber">
                                                      <Translatable id="memoOrInvoiceNumber" strings= getString={[Function: getString]} dispatch={[Function: dispatch]}>
                                                        <span className={[undefined]} />
                                                      </Translatable>
                                                    </Connect(Translatable)>
                                                  </div>
                                                </div>
                                              </Block>
                                            </WithSpace>
                                          </WithLayout>
                                        </label>
                                      </Block>
                                    </WithSpace>
                                  </WithLayout>
                                </FormFieldLabel>
                              </Connect(FormFieldLabel)>
                            </WithFormElementId>
                          </WithFormContext>
                        </Connect(WithFormContext)>
                      </Connect(Connect(WithFormContext))>
                      <WithFormElementId className="input" initialValue="memo" onChange={[undefined]} type="text" maxLength={32} placeholder="Optional" deleteOnUnmount={true}>
                        <WithFormContext className="input" initialValue="memo" onChange={[undefined]} type="text" maxLength={32} placeholder="Optional" deleteOnUnmount={true} formElementId="A0000002">
                          <Connect(WithDependencies) formId={[undefined]} fieldId="ImRequired" fieldKey="undefined-ImRequired" className="input" initialValue="memo" onChange={[undefined]} type="text" maxLength={32} placeholder="Optional" deleteOnUnmount={true} formElementId="A0000002">
                            <WithDependencies formId={[undefined]} fieldId="ImRequired" fieldKey="undefined-ImRequired" className="input" initialValue="memo" onChange={[undefined]} type="text" maxLength={32} placeholder="Optional" deleteOnUnmount={true} formElementId="A0000002" visible={[undefined]} disabledByCondition={[undefined]} addFormDependency={[Function: addFormDependency]} removeFormDependency={[Function: removeFormDependency]}>
                              <Connect(Wrapped) formId={[undefined]} fieldId="ImRequired" fieldKey="undefined-ImRequired" className="input" initialValue="memo" onChange={[undefined]} type="text" maxLength={32} placeholder="Optional" deleteOnUnmount={true} formElementId="A0000002" disabledByCondition={[undefined]}>
                                <Wrapped formId={[undefined]} fieldId="ImRequired" fieldKey="undefined-ImRequired" className="input" initialValue="memo" onChange={[undefined]} type="text" maxLength={32} placeholder="Optional" deleteOnUnmount={true} formElementId="A0000002" disabledByCondition={[undefined]} dataType={[undefined]} dirty={false} pristine={true} errorMessage="" focused={false} minLength={0} name= required={false} showError={false} value="memo" labelText={[undefined]} submitting={false} disabled={[undefined]} disabledWhen={[undefined]} visibleWhen={[undefined]} onChangeCallback={[undefined]} onChangeValidate={false} transform={[undefined]} defineField={[Function: defineField]} deleteField={[Function: deleteField]} focusField={[Function: focusField]} blurField={[Function: blurField]} changeField={[Function: changeField]}>
                                  <Connect(Connect(FormInput)) fieldId="ImRequired" formId={[undefined]} disabled={[undefined]} fieldKey="undefined-ImRequired" className="input" initialValue="memo" onChange={[undefined]} type="text" maxLength={32} placeholder="Optional" deleteOnUnmount={true} formElementId="A0000002" disabledByCondition={[undefined]} dataType={[undefined]} dirty={false} pristine={true} errorMessage="" focused={false} minLength={0} name= required={false} showError={false} value="memo" labelText={[undefined]} submitting={false} disabledWhen={[undefined]} visibleWhen={[undefined]} onChangeCallback={[undefined]} onChangeValidate={false} transform={[undefined]} defineField={[Function: defineField]} deleteField={[Function: deleteField]} focusField={[Function: focusField]} blurField={[Function: blurField]} changeField={[Function: changeField]}>
                                    <Connect(FormInput) fieldId="ImRequired" formId={[undefined]} disabled={[undefined]} fieldKey="undefined-ImRequired" className="input" initialValue="memo" onChange={[undefined]}
type="text" maxLength={32} placeholder="Optional" deleteOnUnmount={true} formElementId="A0000002" disabledByCondition={[undefined]} dataType={[undefined]} dirty={false} pristine={true} errorMessage="" focused={false} minLength={0} name= required={false} showError={false} value="memo" labelText={[undefined]} submitting={false} disabledWhen={[undefined]} visibleWhen={[undefined]} onChangeCallback={[undefined]} onChangeValidate={false} transform={[undefined]} defineField={[Function: defineField]} deleteField={[Function: deleteField]} focusField={[Function: focusField]} blurField={[Function: blurField]} changeField={[Function: changeField]} labelId="" dispatch={[Function: dispatch]}>
                                      <FormInput fieldId="ImRequired" formId={[undefined]} disabled={[undefined]} fieldKey="undefined-ImRequired" className="input" initialValue="memo" onChange={[undefined]} type="text" maxLength={32} placeholder="Optional" deleteOnUnmount={true} formElementId="A0000002" disabledByCondition={[undefined]} dataType="ALL" dirty={false} pristine={true} errorMessage="" focused={false} minLength={0} name= required={false} showError={false} value="memo" labelText={[undefined]} submitting={false} disabledWhen={[undefined]} visibleWhen={[undefined]} onChangeCallback={[undefined]} onChangeValidate={false} transform={[undefined]} defineField={[Function: defineField]} deleteField={[Function: deleteField]} focusField={[Function: focusField]} blurField={[Function: blurField]} changeField={[Function: changeField]} labelId="" dispatch={[Function: dispatch]} fieldMessageIds="" clearedValue="" el=>
                                        <Connect(Input) id="ImRequired" name= value="memo" type="text" placeholder="Optional" maxLength={32} minLength={0} disabled={[undefined]} required={false} invalid={false} inputRef={[Function: inputRef]} labelId="" fieldMessageIds="" className="input" clearable={[undefined]} clearedValue="" clearLabel={[undefined]} onClear={[Function: onClear]} formId={[undefined]} fieldKey="undefined-ImRequired" initialValue="memo" deleteOnUnmount={true} formElementId="A0000002" disabledByCondition={[undefined]} dataType="ALL" dirty={false} pristine={true} errorMessage="" focused={false} labelText={[undefined]} submitting={false} disabledWhen={[undefined]} visibleWhen={[undefined]} onChangeCallback={[undefined]} onChangeValidate={false} transform={[undefined]} defineField={[Function: defineField]} deleteField={[Function: deleteField]} focusField={[Function: focusField]} blurField={[Function: blurField]} changeField={[Function: changeField]} dispatch={[Function: dispatch]} onBlur={[Function: onBlur]} onFocus={[Function: onFocus]} onInput={[Function: onInput]} onTouchEnd={[Function: onTouchEnd]}>
                                          <Input id="ImRequired" name= value="memo" type="text" placeholder="Optional" maxLength={32} minLength={0} disabled={false} required={false} invalid={false} inputRef={[Function: inputRef]} labelId="" fieldMessageIds="" className="input" clearable={false} clearedValue="" clearLabel={[undefined]} onClear={[Function: onClear]} formId={[undefined]} fieldKey="undefined-ImRequired" initialValue="memo" deleteOnUnmount={true} formElementId="A0000002" disabledByCondition={[undefined]} dataType="ALL" dirty={false} pristine={true} errorMessage="" focused={false} labelText={[undefined]} submitting={false} disabledWhen={[undefined]} visibleWhen={[undefined]} onChangeCallback={[undefined]} onChangeValidate={false} transform={[undefined]} defineField={[Function: defineField]} deleteField={[Function: deleteField]} focusField={[Function: focusField]} blurField={[Function: blurField]} changeField={[Function: changeField]} dispatch={[Function: dispatch]} onBlur={[Function: onBlur]} onFocus={[Function: onFocus]} onInput={[Function: onInput]} onTouchEnd={[Function: onTouchEnd]} isModalOpen={false} topChildWindowId={[undefined]} useWFFonts={false} autoComplete="off" filterKeys={[Function: filterKeys]} transformValue={[Function: transformValue]} ariaLabelIds="" ariaDescribeIds="" ariaProps= busy={false} sensitive={false}>
                                            <WithLayout className="inputContainer input">
                                              <WithSpace className="inputContainer input" style=>
                                                <Block className="inputContainer input" style= el="div">
                                                  <div className="inputContainer input" style=>
                                                    <input id="ImRequired" className="" name= maxLength={32} minLength={0} type="text" value="memo" placeholder="Optional" disabled={false} onInput={[Function]} onKeyDown={[Function]} onChange={[Function]} onFocus={[Function]} onBlur={[Function]} onCut={[Function]}
onPaste={[Function]} onTouchEnd={[Function]} autoComplete="off" role={[undefined]} aria-required={false} aria-invalid={false} />
                                                  </div>
                                                </Block>
                                              </WithSpace>
                                            </WithLayout>
                                          </Input>
                                        </Connect(Input)>
                                      </FormInput>
                                    </Connect(FormInput)>
                                  </Connect(Connect(FormInput))>
                                </Wrapped>
                              </Connect(Wrapped)>
                            </WithDependencies>
                          </Connect(WithDependencies)>
                        </WithFormContext>
                      </WithFormElementId>
                      <WithFormContext>
                        <WithFormElementId formId={[undefined]} fieldId="ImRequired" fieldKey="undefined-ImRequired">
                          <Connect(FormFieldErrors) formId={[undefined]} fieldId="ImRequired" fieldKey="undefined-ImRequired" formElementId="A0000003">
                            <FormFieldErrors formId={[undefined]} fieldId="ImRequired" fieldKey="undefined-ImRequired" formElementId="A0000003" fieldErrors= addFieldMessage={[Function: addFieldMessage]} removeFieldMessage={[Function: removeFieldMessage]}>
                              <WithLayout id="A0000003">
                                <WithSpace id="A0000003" style=>
                                  <Block id="A0000003" style= el="div">
                                    <div id="A0000003" style= />
                                  </Block>
                                </WithSpace>
                              </WithLayout>
                            </FormFieldErrors>
                          </Connect(FormFieldErrors)>
                        </WithFormElementId>
                      </WithFormContext>
                    </FormField>
                  </div>
                </Block>
              </WithSpace>
            </WithLayout>
          </Memo>
        </Provider>
      </MockStoreProvider>

Aucun commentaire:

Enregistrer un commentaire