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

Created test for dependency-discovery service #2903

Merged
merged 1 commit into from
Feb 17, 2022

Conversation

TueeNguyen
Copy link
Contributor

Issue This PR Addresses

Fixes #2826

Type of Change

  • Bugfix: Change which fixes an issue
  • New Feature: Change which adds functionality
  • Documentation Update: Change which improves documentation
  • UI: Change which improves UI

Description

  • Add test to dependency-discovery service, and healthcheck of the service to status

Steps to test the PR

  • pnpm install
  • pnpm test src/api/dependency-discovery

Checklist

  • Quality: This PR builds and passes our npm test and works locally
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Screenshots: This PR includes screenshots or GIFs of the changes made or an explanation of why it does not (if applicable)
  • Documentation: This PR includes updated/added documentation to user exposed functionality or configuration variables are added/changed or an explanation of why it does not(if applicable)

@gitpod-io
Copy link

gitpod-io bot commented Feb 12, 2022

@TueeNguyen TueeNguyen requested a review from JerryHue February 12, 2022 21:21
@TueeNguyen TueeNguyen requested a review from joelazwar February 12, 2022 21:21
@TueeNguyen TueeNguyen self-assigned this Feb 12, 2022
@TueeNguyen TueeNguyen added this to the 2.7 Release milestone Feb 12, 2022
@TueeNguyen TueeNguyen added the area: dependency visualization Shows what dependencies are used in Telescope label Feb 12, 2022
JerryHue
JerryHue previously approved these changes Feb 14, 2022
Copy link
Contributor

@JerryHue JerryHue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I believe we might want to also "mock" the source of the dependency list, so that way we won't depend on the actual file specifically. We can then write an e2e that uses the whole output of pnpm list. We can file a follow up issue for that.

src/api/status/src/services.js Outdated Show resolved Hide resolved
const { app } = require('../src');

jest.mock('process', () => ({
cwd: () => 'src/api/dependency-discovery',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with @JerryHue , let's mock the file for the dependency list, so we can write tests against it.


module.exports = {
...baseConfig,
setupFiles: ['<rootDir>/src/api/dependency-discovery/jest.setup.js'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include the root-level jest.setup.js too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. @rclee91 and @JiaHua-Zou had to deal with something similar in other tests where we didn't do this. They can guide you.

@TueeNguyen
Copy link
Contributor Author

@JerryHue I changed the export in dependency-list to getDependencies instead of getDependencies() so that I could mock the function. Is it ok?

@humphd
Copy link
Contributor

humphd commented Feb 16, 2022

D:\.pnpm-store\v3
Error: getCacheEntry failed: connect ETIMEDOUT 13.107.42.16:443

Where are we at with this test failure?

@TueeNguyen
Copy link
Contributor Author

D:\.pnpm-store\v3
Error: getCacheEntry failed: connect ETIMEDOUT 13.107.42.16:443

Where are we at with this test failure?

I reran the checks and it passed, will look into this

RC-Lee
RC-Lee previously approved these changes Feb 16, 2022
Copy link
Contributor

@RC-Lee RC-Lee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran the tests locally and didn't get the error either.
Tests passed

@TueeNguyen TueeNguyen requested a review from RC-Lee February 17, 2022 02:11
Copy link
Contributor

@JerryHue JerryHue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran the test with no issue and it went successful. Nice work!

@TueeNguyen TueeNguyen merged commit a27734b into Seneca-CDOT:master Feb 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: dependency visualization Shows what dependencies are used in Telescope type: test Creation and development of test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add tests for dependency service
5 participants