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

chore: mock data builder for tests #2675

Merged
merged 2 commits into from
Oct 23, 2023
Merged

chore: mock data builder for tests #2675

merged 2 commits into from
Oct 23, 2023

Conversation

iamacook
Copy link
Member

What it solves

Resolves brittle tests

How this PR fixes it

A new Builder class has been added that facilitates mock data generation for tests. An example chainBuilder has been created and used in a few demonstrative tests where useCurrentChain is mocked.

How to test it

Observe the tests passing.

Checklist

  • I've tested the branch on mobile 📱
  • I've documented how it affects the analytics (if at all) 📊
  • I've written a unit/e2e test for it (if applicable) 🧑‍💻

@iamacook iamacook self-assigned this Oct 20, 2023
@github-actions
Copy link

github-actions bot commented Oct 20, 2023

Branch preview

✅ Deploy successful!

https://poc_chain_builder--walletweb.review-wallet-web.5afe.dev

@github-actions
Copy link

github-actions bot commented Oct 20, 2023

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

@github-actions
Copy link

github-actions bot commented Oct 20, 2023

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
74.91% (+0.07% 🔼)
9004/12020
🔴 Branches 48.69% 1806/3709
🔴 Functions
57.24% (+0.28% 🔼)
1340/2341
🟡 Lines
76.5% (+0.07% 🔼)
8139/10639
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟢
... / chains.ts
91.43% 100% 86.67% 93.94%
🟢
... / Builder.ts
100% 100% 100% 100%
🟢
... / utils.ts
100% 100% 100% 100%

Test suite run success

961 tests passing in 133 suites.

Report generated by 🧪jest coverage report action from 5a671c8

Comment on lines 29 to 31
.with('address', faker.finance.ethereumAddress())
.with('txHash', faker.string.hexadecimal())
.with('api', faker.internet.url({ appendSlash: false }))
Copy link
Member

Choose a reason for hiding this comment

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

This with is extremely boilerplaity. Why can't it just be an object?

Copy link
Member Author

Choose a reason for hiding this comment

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

It can. I've changed it to accept Partial<T> instead.

@katspaugh katspaugh changed the title feat: mock data builder for tests chore: mock data builder for tests Oct 20, 2023
Copy link
Member

@katspaugh katspaugh left a comment

Choose a reason for hiding this comment

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

🦾

@iamacook iamacook merged commit b1b5871 into dev Oct 23, 2023
@iamacook iamacook deleted the poc-chain-builder branch October 23, 2023 06:54
@github-actions github-actions bot locked and limited conversation to collaborators Oct 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants