-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add jest config #6
Conversation
depngn 12.0.0 --reporter=json | ||
` | ||
|
||
console.log(usage); |
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.
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.
oohh, i actually kind of like this!
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.
the only weird thing that might pop up is if we set up automatic formatting/linting -- it might mistakenly try to "fix" this and add even more padding. we can cross that bridge when we come to it though.
createUsage(); | ||
|
||
const usage = ` | ||
Usage: |
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.
This doesn't have the wrong indentation, it must be like that in order to match what createUsage()
returns.
@@ -23,3 +23,6 @@ dist-ssr | |||
*.njsproj | |||
*.sln | |||
*.sw? | |||
|
|||
# testing | |||
coverage/ |
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.
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.
Awesome, thanks!! I just had a couple suggestions, but it mostly LGTM!
I actually started work on this on Friday, but I did mostly the same stuff as you (with the addition of my comments/requests).
jest.config.ts
Outdated
collectCoverage: true, | ||
|
||
// An array of glob patterns indicating a set of files for which coverage information should be collected | ||
// collectCoverageFrom: undefined, |
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.
can we specify which files to collect from and which ones to ignore? something like:
// collectCoverageFrom: undefined, | |
collectCoverageFrom: [ | |
'src/**/*.ts', | |
'!src/**/index.ts', | |
'!src/**/types.ts' | |
], |
tests/cli/usage.spec.ts
Outdated
@@ -0,0 +1,28 @@ | |||
import { describe, expect, it, jest } from '@jest/globals'; |
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.
can we use the globals that don't have to be imported? i know "magic" values aren't always the best, but it seems to be the common convention when using jest
.
I think you can npm install -D @types/jest
and then add "jest"
to the types
array in tsconfig.json
.
depngn 12.0.0 --reporter=json | ||
` | ||
|
||
console.log(usage); |
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.
oohh, i actually kind of like this!
depngn 12.0.0 --reporter=json | ||
` | ||
|
||
console.log(usage); |
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.
the only weird thing that might pop up is if we set up automatic formatting/linting -- it might mistakenly try to "fix" this and add even more padding. we can cross that bridge when we come to it though.
comments addressed, @kindoflew! |
Interesting Notes:
How to configure jest with typescript? https://jestjs.io/docs/getting-started
Reference to globals in jest? https://jestjs.io/docs/api
How to mock in jest? https://jestjs.io/docs/mock-function-api#typescript-usage