-
Notifications
You must be signed in to change notification settings - Fork 94
WIP: feat(cypress_test): introduce rule #261
Conversation
@Toxicable this seems quite exciting also for us, is there a reason this is in rules_typescript rather than rules_nodejs? As in this could also just be used with normal js, right? |
@Globegitter I wanted to ensure this worked with TS, but you're right it should be in rules_nodejs. |
So I tried doing a bit more work on this but ran into a few road blocks. I don't know how to write a file (cypress.json) as part of of the test setup, right now you can see that im using
But the path that bazel provides me with is back to the source file, but I need the cypress.json to be copied into the directory with the test files aka: Execute root, I don't know how to get this file there. To work around the Cypress FS issues I was planning on using a fork in the meanwhile |
@Toxicable if you have a look here: https://docs.bazel.build/versions/master/test-encyclopedia.html#initial-conditions there is apparently an env variable I know other users of bazel had a similiar issue with jest snapshot tests and there is some discussion around that here: jestjs/jest#6143 Otherwise maybe a custom rule could be written that tells bazel to create this file and then possibly you could just write into it. But that would be quite a bit more effort. It also seems that |
@Globegitter Thanks for the resources! I think a custom rule is going to have to be the way to proceed here |
@Toxicable I see you are making some progress with the native rule. Is it working now? OR at least looking more promising? |
@Globegitter I made some progress; this is my latest: https://github.com/bazelbuild/rules_typescript/blob/e664c44ae372e0efd8b758b930364ff318081f49/internal/cypress_test/cypress_test.bzl
Unfortunately I cant use fine grained deps to do this just yet since our repo isn't upgraded due to some issues with debugging nodejs code, however it should still be doable without it. |
@Toxicable yeah runfiles can sometimes be a bit tricky, I commented on an issue related to that once (can't find it anymore) but the api is a bit confusing and redundant. I will try and make some time to test this out myself in the coming days. Have you tried adding it to |
@Globegitter No luck on that one just yet. For the first issue:
which do: https://docs.bazel.build/versions/master/skylark/lib/ctx.html#runfiles
But the cypress executable is not in srcs, data or deps, nor do I see how I'm meant to add cypress to those attriibutes or how it's done in the karma rule im looking at. For the second:
which I can see when iterating it I can see here: https://github.com/bazelbuild/rules_typescript/blob/master/internal/karma/ts_web_test.bzl#L82 |
@Toxicable I'm going to close this PR now that rules_nodejs is a monorepo with packages/ subdirs. Want to introduce the cypress subdirectory there? |
I've opened a ticket in the rules_nodejs repo: bazel-contrib/rules_nodejs#607 |
Prototype of rule for running intergration tests with Cypress.
Right now it's only for
cypress run
(CI version) since there's another issue (see below) withcypress open
(dev version)Also it only works with
bazel run
since with bazel test due to the issues with bazel wanting to write files (see below)These two issues are blocking the use of
bazel test
cypress-io/cypress#1281
This one is blocking
cypress open
cypress-io/cypress#1925