-
Notifications
You must be signed in to change notification settings - Fork 522
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
Rules for running jest tests #395
Conversation
@vmax thanks for getting started on this, that is awesome, we are using jest internally in a quite hacky way so far and I have not been able yet to write a proper rule, so happy to see something happening here. Generale comments: I wonder if it makes sense to stick to the existing naming and name this I am also seeing you are copying the file to get around the jest symlink issue: jestjs/jest#5356 - I wonder if there is also a better way of getting around this as I could imagine that impacting performance once you reach a certain number of tests. I know it is possible to run Also can you provide examples? This is a simple way of being able to tests the functionality but also to show how to use the rules. |
Ahh I am also just seeing #394 for naming - yeah that also makes some sense. |
/cc @FrozenPandaz since we just discussed it |
I had more of a play with it and no matter how jest is invoked it does not recognize symlinks. I do have started adding symlink support to jest a while ago, here is an incomplete PR: jestjs/jest#7364 If anyone wants to help finish it up quicker. I also had a brief look into creating our own runner that bypasses the whole jest symlink logic but it was not easy to figure out where exactly to plug that in and it does not seem to be officially supported, see: https://stackoverflow.com/questions/50827216/use-jest-run-or-jest-runcli-to-run-all-tests-or-ways-to-run-jest-programmati & jestjs/jest#3737 |
@Globegitter AFAICT you can avoid the Jest symlinks issue entirely by using the In case it helps, here's our entry_point script for running jest tests: https://gist.github.com/dicarlo2/7b920185b28058f7f7379ad39834472b. We use a modified set of rules from this repo, so there may be some differences that I'm not accounting for, but this might give some ideas on how to make jest work. At a high level, we just call |
@dicarlo2 thanks for posting that, that is pretty useful - will take a look. |
@dicarlo2 Do you also have the set of rules that you are using with this runner? Or some more hints? |
@Globegitter Here's the rules file: https://gist.github.com/dicarlo2/3f35d9ef183a0cfe856997b7122a105a Note that we are using a slightly customized variant of Also, FWIW this is one of the first rules I wrote for bazel and I haven't updated it since, so it may be doing some janky things. |
@dicarlo2 Thanks for posting this, that was enough for me to also put together a set of jest_rules I have here: https://github.com/ecosia/bazel_rules_nodejs_contrib/tree/jest-rules/internal/nodejs_jest_test I changed things a bit to make it more conformant with test rules from other languages. Feel free to have a look if you are interested :) |
We've switched our primary test framework to be Jasmine such that the officially supported rule is used. Therefore, we no longer plan on supporting |
Closes bazel-contrib#395 PiperOrigin-RevId: 231848839
Closes bazel-contrib#395 PiperOrigin-RevId: 231848839
No description provided.