-
Notifications
You must be signed in to change notification settings - Fork 573
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
Remove @types/jest
, and use Jest's own type annotations instead
#5113
Conversation
8a381ed
to
6679059
Compare
ironfish-cli/src/testSetup.ts
Outdated
const it: Global.GlobalAdditions['it'] | ||
const test: Global.GlobalAdditions['test'] | ||
const fit: Global.GlobalAdditions['fit'] | ||
const xit: Global.GlobalAdditions['xit'] | ||
const xtest: Global.GlobalAdditions['xtest'] | ||
const describe: Global.GlobalAdditions['describe'] | ||
const xdescribe: Global.GlobalAdditions['xdescribe'] | ||
const fdescribe: Global.GlobalAdditions['fdescribe'] | ||
const beforeAll: Global.GlobalAdditions['beforeAll'] | ||
const beforeEach: Global.GlobalAdditions['beforeEach'] | ||
const afterEach: Global.GlobalAdditions['afterEach'] | ||
const afterAll: Global.GlobalAdditions['afterAll'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If any TypeScript expert knows how to put everything from Global.GlobalAdditions
into the global namespace with 1 line, please let me know!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const {
it,
test,
fit,
xit,
xtest,
describe,
xdescribe,
fdescribe,
beforeAll,
beforeEach,
afterEach,
afterAll,
}: Global.GlobalAdditions;
Does this work for what you want?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's better, thanks. What I would really like to do is avoiding writing it
, test
, fit
, xit
, ... I would like to do something like import * from Global.GlobalAdditions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think TS has a way to import all properties from a type into the global namespace, but maybe someone else knows a better way.
6679059
to
8d1f93e
Compare
8d1f93e
to
8c16d8d
Compare
Summary
This removes
@types/jest
in favor of@jest/types
and friends. This allows using jest and expect to their full potential, and allow using new features like this: https://github.com/iron-fish/ironfish/blob/d8dffe54b17a3555efb013230726c3bb19eef784/ironfish/src/testUtilities/matchers/transaction.ts.@types/jest
was probably added at a time when Jest did not have any type annotations, but now that jest does have the annotations, it makes sense (in my opinion) to switch to using those. Some drawbacks:In addition to removing
@types/jest
, this PR also:mockResolvedValue(Promise.resolved(x))
withmockResolvedValue(x)
toMatchObject(x)
withtoEqual(x)
Testing Plan
Documentation
N/A
Breaking Change
N/A