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] Clean and investigate console errors/warnings in unit tests #554

Open
2 of 3 tasks
ananzh opened this issue Jun 25, 2021 · 0 comments
Open
2 of 3 tasks

[Test] Clean and investigate console errors/warnings in unit tests #554

ananzh opened this issue Jun 25, 2021 · 0 comments
Labels
good first issue Good for newcomers technical debt If not paid, jeapardizes long-term success and maintainability of the repository. test:unit

Comments

@ananzh
Copy link
Member

ananzh commented Jun 25, 2021

Describe the bug

Currently, there are many console.errors in the unit test. To build a clean unit test, we want to investigate these console errors and clean up if possible. Some examples are:

 PASS  src/core/public/application/ui/app_container.test.tsx
  ● Console

    console.error
      [React Intl] Could not find required `intl` object. <IntlProvider> needs to exist in the component ancestry. Using default message as fallback.

      at defaultFormatMessage (node_modules/react-intl/lib/index.js:1533:13)
      at FormattedMessage.render (node_modules/react-intl/lib/index.js:1638:30)
      at finishClassComponent (node_modules/react-dom/cjs/react-dom.development.js:18470:31)
      at updateClassComponent (node_modules/react-dom/cjs/react-dom.development.js:18423:24)
      at beginWork$1 (node_modules/react-dom/cjs/react-dom.development.js:20186:16)
      at beginWork$$1 (node_modules/react-dom/cjs/react-dom.development.js:25756:14)
      at performUnitOfWork (node_modules/react-dom/cjs/react-dom.development.js:24698:12)
      at workLoopSync (node_modules/react-dom/cjs/react-dom.development.js:24671:22)
 FAIL  packages/osd-telemetry-tools/src/tools/manage_schema.test.ts (5.505 s)
  ● generateMapping › generates a mapping file

    : Timeout - Async callback was not invoked within the 5000 ms timeout specified by jest.setTimeout.Timeout - Async callback was not invoked within the 5000 ms timeout specified by jest.setTimeout.Error:

      45 | 
      46 | describe('generateMapping', () => {
    > 47 |   it('generates a mapping file', async () => {
         |   ^
      48 |     const mockSchema = await parseJsonFile('mock_schema.json');
      49 |     const result = generateMapping([parsedWorkingCollector]);
      50 |     expect(result).toEqual(mockSchema);

      at new Spec (node_modules/jest-jasmine2/build/jasmine/Spec.js:116:22)
      at Suite.Object.<anonymous>.describe (packages/osd-telemetry-tools/src/tools/manage_schema.test.ts:47:3)
      at Object.<anonymous> (packages/osd-telemetry-tools/src/tools/manage_schema.test.ts:46:1)

To Reproduce
Run:
yarn test:jest --runInBand --detectOpenHandles --reporters=default

If see an error like this:

$ node scripts/jest --runInBand --detectOpenHandles
Error: An error occurred while adding the reporter at path "/home/anan/work/OpenSearch-Dashboards/src/dev/jest/junit_reporter.js".In database main: Invalid argument
    at renewReadTxn (/home/anan/work/OpenSearch-Dashboards/node_modules/lmdb-store/index.js:79:11)
    at LMDBStore.get (/home/anan/work/OpenSearch-Dashboards/node_modules/lmdb-store/index.js:205:39)
    at Cache.getMtime (/home/anan/work/OpenSearch-Dashboards/packages/osd-optimizer/src/node/cache.ts:112:24)
    at compile (/home/anan/work/OpenSearch-Dashboards/packages/osd-optimizer/src/node/node_auto_tranpilation.ts:98:15)
    at /home/anan/work/OpenSearch-Dashboards/packages/osd-optimizer/src/node/node_auto_tranpilation.ts:169:16
    at Module._compile (/home/anan/work/OpenSearch-Dashboards/node_modules/pirates/lib/index.js:93:29)
    at Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Object.newLoader [as .js] (/home/anan/work/OpenSearch-Dashboards/node_modules/pirates/lib/index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)

then pass ab argument:
yarn test:jest --runInBand --detectOpenHandles --reporters=default

Expected behavior
explore each problem unit test and do the following step for each test suite

  1. create a sub issue for each test suite
  2. check the following questions:
  • 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

Sub issues

  • Investigate console error in telemetry_management_section.test.tsx
    issue: #555
  • Investigate console warnings in get_local_stats.test.ts
    issue: #556
  • Investigate console error in telemetry_service.test.ts
    issue: #557
@ananzh ananzh self-assigned this Jun 25, 2021
@ananzh ananzh changed the title [Test] Clean skipped unit tests [Test] Clean and investigate console errors/warnings in unit tests Jun 25, 2021
@ananzh ananzh closed this as completed Aug 5, 2021
@ananzh ananzh reopened this Aug 5, 2021
@tmarkley tmarkley added the technical debt If not paid, jeapardizes long-term success and maintainability of the repository. label May 25, 2022
@ananzh ananzh removed their assignment Oct 18, 2022
@ananzh ananzh added the good first issue Good for newcomers label Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers technical debt If not paid, jeapardizes long-term success and maintainability of the repository. test:unit
Projects
None yet
Development

No branches or pull requests

2 participants