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

Added testcases for Tokens & TotalAmount Component #1629

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

NitinRamnani
Copy link

I've added testcases for Tokens & TotalAmount Components which have increased code coverage of those components.

Before PR:

Before PR

After PR:

After PR

After PR -2

Copy link
Collaborator

@CedrikNikita CedrikNikita left a comment

Choose a reason for hiding this comment

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

This two million lines generated files look like a mistake to me.

@NitinRamnani
Copy link
Author

Fixed the snapshot testcases to compare HTML instead of vm of the component.

let wrapper;

describe('TokenAmount', () => {
beforeEach(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is no need to have a beforeEach and a wrapper variable deinfed out of scope, since you have only one test.

mocks: {
$store: {
state: {},
getters: {},
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can import and use particular getters instead of mocking them, in order to cover all the cases in the TokenAmount component.

@@ -21,6 +21,7 @@ module.exports = {
'<rootDir>/config/jest/setEnvVars.js',
'<rootDir>/config/jest/setup.js',
],
collectCoverage: true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we need to collect coverage on every run of test:unit command. I think it would be better to track coverage differently.
#1778

/tests/e2e/screenshots
/tests/e2e/videos/
/tests/e2e/screenshots/
/coverage
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think all changes to this file should be undone.

@@ -0,0 +1,34 @@
import { shallowMount } from '@vue/test-utils';
import Tokens from '../../src/popup/components/Tokens.vue';
Copy link
Collaborator

@CedrikNikita CedrikNikita Jan 13, 2023

Choose a reason for hiding this comment

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

This test is not covering all the potential cases of Tokens component.

@CedrikNikita
Copy link
Collaborator

The PR should be properly rebased to consist only of meaningful commits, also commit names should be align with the template we are using in this repo.
https://www.conventionalcommits.org/en/v1.0.0/

@CedrikNikita
Copy link
Collaborator

CedrikNikita commented Jan 13, 2023

In general, I would skip matching the snapshot and would rather test the logic of the component, because:

  • if we will change the class name the snapshot matching would fail;
  • we would need to update none markup based tests less often

@subhod-i
Copy link
Contributor

@NitinRamnani There are few suggestions, would you work on fixing it? We can merge this once the PR is approved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants