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

Making of Jest Runner Integration #154

Open
idangoldman opened this issue Sep 29, 2019 · 6 comments
Open

Making of Jest Runner Integration #154

idangoldman opened this issue Sep 29, 2019 · 6 comments

Comments

@idangoldman
Copy link

Hello,

I love True and it helped me write tests for SCSS, now I want to help it and make a Jest runner package for it.

Before starting, I wanted to get your view on the matter and what should I know from the True side that will come in handy and make this integration easier?

@idangoldman idangoldman changed the title Making of a Jest Runner Integration Making of Jest Runner Integration Sep 29, 2019
@mirisuzanne
Copy link
Member

Thanks @idangoldman! @jgerigmeyer do you want to jump in here?

@jgerigmeyer
Copy link
Member

Sounds good to me! I don't have a lot of experience with custom Jest runners, but I'd be happy to test/review a PR when you have one ready. Do you have specific questions about True integration with Jest? See our docs or package.json for how True is already testing itself using Jest.

@idangoldman
Copy link
Author

Ok, thanks for the support! I will play with some code and let you review and test what I will come up with.

@idangoldman
Copy link
Author

20 days later and here is the kickstart stone for SASS True jest runner.

You can go over the git repo of the runner here-> jest-runner-sass-true

The only roadblock holding it from working properly is that I wasn't able to inject Jest's describe and it into the runner for sassTrue.runSass to work properly (it works fine until it needs describe and it 😇).

This is a bit weird because Jest runs globally but for some reason it's not running globally inside the runner. Any ideas?

There are a couple of tickets about making Jest's importable and not only run globally. There is even a PR (Allow importing Jest as an ES6 module #7571) on the subject but the Jest Team doesn't seem to have a priority for this. The discussion on the PR page suggests a couple of workaround solutions that I had no luck implementing. Any ideas?

While working on the runner I had the chance to look at lib/main and describeModule function. From the look of it, describe and it functions can be replaced by a function(string, callback) which will aggregate all the strings and prompt them with chalk at the end of the loop. That way True can be decoupled from any test runner and ran standalone.

It would be great if lib/main expose an API that will return a list of ran tests (failed and succeed). This way it will be much easier to feed it to another test runner or just prompt it to the terminal with a CLI wrapper.

Any thoughts? :)

@jgerigmeyer
Copy link
Member

@idangoldman Sorry for the delay -- I just played with your custom runner a bit.

This is a bit weird because Jest runs globally but for some reason it's not running globally inside the runner. Any ideas?

Yeah... that is weird. 🤷‍♂ It seems like custom runners themselves don't run in the "Jest" environment -- so there's not an obvious way to access describe and it.

While working on the runner I had the chance to look at lib/main and describeModule function. From the look of it, describe and it functions can be replaced by a function(string, callback) which will aggregate all the strings and prompt them with chalk at the end of the loop. That way True can be decoupled from any test runner and ran standalone.

It would be great if lib/main expose an API that will return a list of ran tests (failed and succeed). This way it will be much easier to feed it to another test runner or just prompt it to the terminal with a CLI wrapper.

Interesting. I actually like the idea of decoupling True from test runners, if possible. Would you be interested in submitting a PR to True to get things started? Thanks!

@idangoldman
Copy link
Author

@jgerigmeyer Sorry for my delay as well... Missed the notification 😅

Interesting. I actually like the idea of decoupling True from test runners, if possible. Would you be interested in submitting a PR to True to get things started? Thanks!

Yeah of course, didn't want to start writing anything before getting an approval from you. I will throw something together and submit a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants