Conversation
was curious about this, here is what I found useful to understand: toMatchFormat: (format, config = {}) => checkFormat(format, format, config)
const checkFormat = (before, after, config) => {
const options = Object.assign({}, { parser: "ruby", plugins: ["."] }, config);
const actual = prettier.format(before, options);
return {
pass: actual === `${after}\n`,
message: () => `Expected:\n ${after}\nReceived:\n ${actual}`
};
};ok, so it's checking for idempotence, quite nice |
johnschoeman
left a comment
There was a problem hiding this comment.
Overall this looks great to me, and is an impressive amount of work! I had a question, if you have a moment to answer. Let me know if you want any help finishing the expectations in some of the tests.
| (hasBody || variables) ? " " : "", | ||
| variables ? path.call(print, "body", 0) : "", | ||
| path.call(print, "body", 1), | ||
| " }" |
| }); | ||
|
|
||
| expect.extend({ | ||
| toChangeFormat(before, after, config = {}) { |
There was a problem hiding this comment.
I like being able to be explicit about the config here!
| @@ -0,0 +1,74 @@ | |||
| const { spawn } = require("child_process"); | |||
There was a problem hiding this comment.
This looks great to me. Just to make sure I'm understanding correctly, the reason you are going with jest here as opposed to rspec or minitest is for performance reasons? or is there something else that makes jest preferable?
There was a problem hiding this comment.
There are a couple of reasons. The #1 is speed - shelling out to ruby -c and rubocop and minitest takes a ton of time. I'd still like to bring that back, but only in an integration test capacity that doesn't need to run for the whole unit test suite. #2 is test coverage. It's really hard to measure test coverage when we're using ruby specs versus just using the stuff built into jest. #3 is the convenience of jest itself (test.only, describe.each, etc.). There's a lot of stuff baked in that makes it pretty nice to work with.
There was a problem hiding this comment.
Sounds good to me. Thanks for the explanation.
Okay so this is a big one. A couple of reasons for it:
Here's what this PR does:
I want to write up some docs and start incorporating some of the open PRs into this work, but I figured I'd open this up now.