-
Notifications
You must be signed in to change notification settings - Fork 30
Transition to Jest, Increase Languages Tested, and Fix Bug with Sub-Languages #10
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #10 +/- ##
=========================================
+ Coverage 63.26% 64.7% +1.44%
=========================================
Files 2 2
Lines 49 51 +2
Branches 9 10 +1
=========================================
+ Hits 31 33 +2
Misses 18 18
Continue to review full report at Codecov.
|
Why the change to jest? |
Primarily to make use of Snapshots. |
Could you explain that feature or link me to docs? I am always a bit reluctant to switch to different frameworks without evaluating the pros/cons. |
No worries. Totally get it. Currently this repo takes an input and tracks it against an expected output. Snapshots simply automate the tracking of the expected output by placing it in external snapshot files. This is super helpful for dynamically generated tests, which this PR also does by looping through fixtures and testing against them. For more on Snapshot testing here's a talk from React Conf 2017 about it, and the documentation on Snapshot Testing |
I generally like to compose unopinionated libraries, and jest looks very opinionated on first sight (all the file naming conventions, included assertions and coverage tools, ...) but this sounds like a useful feature that would require boilerplate to replicate with mocha. |
.travis.yml
Outdated
@@ -16,11 +16,9 @@ install: | |||
|
|||
script: | |||
- npm run lint | |||
- npm run build |
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 would still like to run this in CI to see if the compilation has any errors.
Then of course the compilation that jest does is a bit redundant, is it possible to just run jet from the output JS?
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.
To work with TypeScript I set up Jest to use a package called ts-jest
. Running tsc before Jest wouldn't have any effect on the tests. Happy to add it back
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.
So it's not possible to just run the generated .js files with jest?
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.
It's possible. Using ts-jest ensures that code coverage reports produced are accurate. But it's not necessary jestjs/jest#336 (comment) https://github.com/codecov/example-typescript/issues/7
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.
Okay, that's a priority of course. Compilation should be fast so not worried that much.
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.
So what were you thinking on this one? Stick with ts-jest
or, compile then test like in the SourceGraph example?
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.
We can use ts-jest. What do you mean with Sourcegraph example?
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.
Err. My bad. The Codecov example. https://github.com/codecov/example-typescript
src/test/test.ts
Outdated
} else { | ||
console.log(highlighted + '\n') | ||
|
||
if (process.env.VERBOSE) { |
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 you set this in CI? In opposite to the previous assertion way, the snapshot files contain the raw ANSI codes, which is impossible to code review. Printing the coloured output in CI is a good and easy way to verify that the changes the snapshots were correct.
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.
Of course!
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.
Printing code samples on CI now https://travis-ci.org/felixfbecker/cli-highlight/builds/306902109
|
||
after_success: | ||
- nyc report --reporter=json |
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.
jest seems to always generate JSON, lcov and clover format, which are then all three uploaded to codecov. I am a bit worried that if one format is better than the other (does lcov support sub-line coverage?) we get the lowest common denominator of features as codecov merges the coverage. Is there a way to only tell jest to generate JSON?
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 do using this configuration option
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.
Cool, lets set that to text-summary
and json
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 will allow for easier test growth in the near future
This unviels a few important issues hence failing tests
Woot! 🎉 Thank you! |
Thanks for your contributions! You turned this into a really solid module |
No description provided.