Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Test] Investigate console warnings in field_editor.test.tsx #673

Closed
ananzh opened this issue Jul 27, 2021 · 0 comments
Closed

[Test] Investigate console warnings in field_editor.test.tsx #673

ananzh opened this issue Jul 27, 2021 · 0 comments
Assignees

Comments

@ananzh
Copy link
Member

ananzh commented Jul 27, 2021

Describe the issue

Currently, field_editor.test.tsx prints out console warnings when run the unit test. To make a clean unit test, we want to explore the reasons for these errors/warnings and decide whether we could fix or remove them.

  console.error
    Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

      593 |           error={isInvalid ? errorMsg : null}
      594 |         >
    > 595 |           <EuiCodeEditor
          |           ^
      596 |             value={spec.script}
      597 |             data-test-subj="editorFieldScript"
      598 |             onChange={this.onScriptChange}

      at warningWithoutStack (node_modules/react/cjs/react.development.js:167:32)
      at warning (node_modules/react/cjs/react.development.js:638:27)
      at Object.createElementWithValidation [as createElement] (node_modules/react/cjs/react.development.js:2035:5)
      at FieldEditor.renderScript (src/plugins/index_pattern_management/public/components/field_editor/field_editor.tsx:595:11)
      at FieldEditor.render (src/plugins/index_pattern_management/public/components/field_editor/field_editor.tsx:896:17)
      at ReactShallowRenderer._updateClassComponent (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:977:39)
      at ReactShallowRenderer.render (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:810:12)
      at Updater.enqueueSetState (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:412:20)
      at FieldEditor.Object.<anonymous>.Component.setState (node_modules/react/cjs/react.development.js:325:16)
      at fn (node_modules/enzyme/src/ShallowWrapper.js:802:11)
      at withSetStateAllowed (node_modules/enzyme/src/Utils.js:253:3)
      at ShallowWrapper.call (node_modules/enzyme/src/ShallowWrapper.js:743:7)
      at ShallowWrapper.single (node_modules/enzyme/src/ShallowWrapper.js:1654:21)

  console.error
    Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

      593 |           error={isInvalid ? errorMsg : null}
      594 |         >
    > 595 |           <EuiCodeEditor
          |           ^
      596 |             value={spec.script}
      597 |             data-test-subj="editorFieldScript"
      598 |             onChange={this.onScriptChange}

      at warningWithoutStack (node_modules/react/cjs/react.development.js:167:32)
      at warning (node_modules/react/cjs/react.development.js:638:27)
      at Object.createElementWithValidation [as createElement] (node_modules/react/cjs/react.development.js:2035:5)
      at FieldEditor.renderScript (src/plugins/index_pattern_management/public/components/field_editor/field_editor.tsx:595:11)
      at FieldEditor.render (src/plugins/index_pattern_management/public/components/field_editor/field_editor.tsx:896:17)
      at ReactShallowRenderer._updateClassComponent (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:977:39)
      at ReactShallowRenderer.render (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:810:12)
      at Updater.enqueueSetState (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:412:20)
      at FieldEditor.Object.<anonymous>.Component.setState (node_modules/react/cjs/react.development.js:325:16)
      at fn (node_modules/enzyme/src/ShallowWrapper.js:802:11)
      at withSetStateAllowed (node_modules/enzyme/src/Utils.js:253:3)
      at ShallowWrapper.call (node_modules/enzyme/src/ShallowWrapper.js:743:7)
      at ShallowWrapper.single (node_modules/enzyme/src/ShallowWrapper.js:1654:21)

  console.error
    Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

      593 |           error={isInvalid ? errorMsg : null}
      594 |         >
    > 595 |           <EuiCodeEditor
          |           ^
      596 |             value={spec.script}
      597 |             data-test-subj="editorFieldScript"
      598 |             onChange={this.onScriptChange}

      at warningWithoutStack (node_modules/react/cjs/react.development.js:167:32)
      at warning (node_modules/react/cjs/react.development.js:638:27)
      at Object.createElementWithValidation [as createElement] (node_modules/react/cjs/react.development.js:2035:5)
      at FieldEditor.renderScript (src/plugins/index_pattern_management/public/components/field_editor/field_editor.tsx:595:11)
      at FieldEditor.render (src/plugins/index_pattern_management/public/components/field_editor/field_editor.tsx:896:17)
      at ReactShallowRenderer._updateClassComponent (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:977:39)
      at ReactShallowRenderer.render (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:810:12)
      at Updater.enqueueSetState (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:412:20)
      at FieldEditor.Object.<anonymous>.Component.setState (node_modules/react/cjs/react.development.js:325:16)
      at fn (node_modules/enzyme/src/ShallowWrapper.js:802:11)
      at withSetStateAllowed (node_modules/enzyme/src/Utils.js:253:3)
      at ShallowWrapper.call (node_modules/enzyme/src/ShallowWrapper.js:743:7)
      at ShallowWrapper.single (node_modules/enzyme/src/ShallowWrapper.js:1654:21)

  console.error
    Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

      593 |           error={isInvalid ? errorMsg : null}
      594 |         >
    > 595 |           <EuiCodeEditor
          |           ^
      596 |             value={spec.script}
      597 |             data-test-subj="editorFieldScript"
      598 |             onChange={this.onScriptChange}

      at warningWithoutStack (node_modules/react/cjs/react.development.js:167:32)
      at warning (node_modules/react/cjs/react.development.js:638:27)
      at Object.createElementWithValidation [as createElement] (node_modules/react/cjs/react.development.js:2035:5)
      at FieldEditor.renderScript (src/plugins/index_pattern_management/public/components/field_editor/field_editor.tsx:595:11)
      at FieldEditor.render (src/plugins/index_pattern_management/public/components/field_editor/field_editor.tsx:896:17)
      at ReactShallowRenderer._updateClassComponent (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:977:39)
      at ReactShallowRenderer.render (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:810:12)
      at Updater.enqueueSetState (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:412:20)
      at FieldEditor.Object.<anonymous>.Component.setState (node_modules/react/cjs/react.development.js:325:16)
      at fn (node_modules/enzyme/src/ShallowWrapper.js:802:11)
      at withSetStateAllowed (node_modules/enzyme/src/Utils.js:253:3)
      at ShallowWrapper.call (node_modules/enzyme/src/ShallowWrapper.js:743:7)
      at ShallowWrapper.single (node_modules/enzyme/src/ShallowWrapper.js:1654:21)

  console.error
    Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

      593 |           error={isInvalid ? errorMsg : null}
      594 |         >
    > 595 |           <EuiCodeEditor
          |           ^
      596 |             value={spec.script}
      597 |             data-test-subj="editorFieldScript"
      598 |             onChange={this.onScriptChange}

      at warningWithoutStack (node_modules/react/cjs/react.development.js:167:32)
      at warning (node_modules/react/cjs/react.development.js:638:27)
      at Object.createElementWithValidation [as createElement] (node_modules/react/cjs/react.development.js:2035:5)
      at FieldEditor.renderScript (src/plugins/index_pattern_management/public/components/field_editor/field_editor.tsx:595:11)
      at FieldEditor.render (src/plugins/index_pattern_management/public/components/field_editor/field_editor.tsx:896:17)
      at ReactShallowRenderer._updateClassComponent (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:977:39)
      at ReactShallowRenderer.render (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:810:12)
      at Updater.enqueueForceUpdate (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:385:20)
      at FieldEditor.forceUpdate (node_modules/react/cjs/react.development.js:344:16)
      at FieldEditor.onFieldChange (src/plugins/index_pattern_management/public/components/field_editor/field_editor.tsx:232:10)
      at Object.it (src/plugins/index_pattern_management/public/components/field_editor/field_editor.test.tsx:222:43)

  console.error
    Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

      593 |           error={isInvalid ? errorMsg : null}
      594 |         >
    > 595 |           <EuiCodeEditor
          |           ^
      596 |             value={spec.script}
      597 |             data-test-subj="editorFieldScript"
      598 |             onChange={this.onScriptChange}

      at warningWithoutStack (node_modules/react/cjs/react.development.js:167:32)
      at warning (node_modules/react/cjs/react.development.js:638:27)
      at Object.createElementWithValidation [as createElement] (node_modules/react/cjs/react.development.js:2035:5)
      at FieldEditor.renderScript (src/plugins/index_pattern_management/public/components/field_editor/field_editor.tsx:595:11)
      at FieldEditor.render (src/plugins/index_pattern_management/public/components/field_editor/field_editor.tsx:896:17)
      at ReactShallowRenderer._updateClassComponent (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:977:39)
      at ReactShallowRenderer.render (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:810:12)
      at Updater.enqueueSetState (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:412:20)
      at FieldEditor.Object.<anonymous>.Component.setState (node_modules/react/cjs/react.development.js:325:16)
      at fn (node_modules/enzyme/src/ShallowWrapper.js:802:11)
      at withSetStateAllowed (node_modules/enzyme/src/Utils.js:253:3)
      at ShallowWrapper.call (node_modules/enzyme/src/ShallowWrapper.js:743:7)
      at ShallowWrapper.single (node_modules/enzyme/src/ShallowWrapper.js:1654:21)

  console.error
    Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

      593 |           error={isInvalid ? errorMsg : null}
      594 |         >
    > 595 |           <EuiCodeEditor
          |           ^
      596 |             value={spec.script}
      597 |             data-test-subj="editorFieldScript"
      598 |             onChange={this.onScriptChange}

      at warningWithoutStack (node_modules/react/cjs/react.development.js:167:32)
      at warning (node_modules/react/cjs/react.development.js:638:27)
      at Object.createElementWithValidation [as createElement] (node_modules/react/cjs/react.development.js:2035:5)
      at FieldEditor.renderScript (src/plugins/index_pattern_management/public/components/field_editor/field_editor.tsx:595:11)
      at FieldEditor.render (src/plugins/index_pattern_management/public/components/field_editor/field_editor.tsx:896:17)
      at ReactShallowRenderer._updateClassComponent (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:977:39)
      at ReactShallowRenderer.render (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:810:12)
      at Updater.enqueueForceUpdate (node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js:385:20)
      at FieldEditor.forceUpdate (node_modules/react/cjs/react.development.js:344:16)
      at FieldEditor.onFieldChange (src/plugins/index_pattern_management/public/components/field_editor/field_editor.tsx:232:10)
      at Object.it (src/plugins/index_pattern_management/public/components/field_editor/field_editor.test.tsx:247:43)

Test Suites: 1 passed, 1 total
Tests:       5 passed, 5 total
Snapshots:   5 passed, 5 total
Time:        3.908 s, estimated 4 s
Ran all test suites matching /src\/plugins\/index_pattern_management\/public\/components\/field_editor\/field_editor.test.tsx/i.
Done in 6.39s.

To Reproduce
Run:yarn test:jest {path to field_editor.test.tsx}

Expected behavior

explore each problem unit test cases and investigate each question:

  • what causes the console error or issues?

  • should this unit test log this error or warning message?

  • if answer to the above question is no, then can we fix it?

The final output is expected to be a cleaned unit test with un-necessary error/warnings been removed.

OpenSearch Version
OpenSearch 1.0.0

Dashboards Version
Dashboards 1.0.0

@ananzh ananzh added bug Something isn't working test:unit v1.1.0 labels Jul 27, 2021
@ananzh ananzh self-assigned this Jul 27, 2021
@ananzh ananzh removed the bug Something isn't working label Jul 27, 2021
ananzh added a commit to ananzh/OpenSearch-Dashboards that referenced this issue Jul 27, 2021
Currently, unit test field_editor.test.tsx shows a console warning:

```React.createElement: type is invalid -- expected a string
(for built-in components) or a class/function (for composite components)
but got: undefined. ```

This warning is because EuiCodeEditor is missing in the mock of elastic/eui,
which causes undefined EuiCodeEditor in the test.

PR Resolved:
opensearch-project#673

Signed-off-by: Anan Zhuang <[email protected]>
@ananzh ananzh closed this as completed in 5b5ac4e Jul 28, 2021
ananzh added a commit to ananzh/OpenSearch-Dashboards that referenced this issue Jul 29, 2021
Currently, unit test field_editor.test.tsx shows a console warning:

```React.createElement: type is invalid -- expected a string
(for built-in components) or a class/function (for composite components)
but got: undefined. ```

This warning is because EuiCodeEditor is missing in the mock of elastic/eui,
which causes undefined EuiCodeEditor in the test.

PR Resolved:
opensearch-project#673

Backport PR:
opensearch-project#674

Signed-off-by: Anan Zhuang <[email protected]>
ananzh added a commit that referenced this issue Jul 29, 2021
Currently, unit test field_editor.test.tsx shows a console warning:

```React.createElement: type is invalid -- expected a string
(for built-in components) or a class/function (for composite components)
but got: undefined. ```

This warning is because EuiCodeEditor is missing in the mock of elastic/eui,
which causes undefined EuiCodeEditor in the test.

PR Resolved:
#673

Backport PR:
#674

Signed-off-by: Anan Zhuang <[email protected]>
tmarkley pushed a commit to tmarkley/OpenSearch-Dashboards that referenced this issue Aug 3, 2021
Previous PR opensearch-project#674 did not include updated snapshots.

Related to opensearch-project#673

Signed-off-by: Tommy Markley <[email protected]>
tmarkley pushed a commit that referenced this issue Aug 4, 2021
Previous PR #674 did not include updated snapshots.

Related to #673

Signed-off-by: Tommy Markley <[email protected]>
tmarkley pushed a commit to tmarkley/OpenSearch-Dashboards that referenced this issue Aug 5, 2021
Previous PR opensearch-project#674 did not include updated snapshots.

Related to opensearch-project#673

Signed-off-by: Tommy Markley <[email protected]>
tmarkley pushed a commit that referenced this issue Aug 6, 2021
Previous PR #674 did not include updated snapshots.

Related to #673

Signed-off-by: Tommy Markley <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant