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

Question: Can this Integrate with a package like knapsack-pro-cypress? #55

Closed
nickytonline opened this issue Jan 7, 2021 · 2 comments
Closed

Comments

@nickytonline
Copy link

nickytonline commented Jan 7, 2021

Thanks for the great project! I'll preface this with I'm a Rails/Ruby newb.

I'm curious if anyone has got this to run with parallelization using knapsack-pro-cypress? I'm guessing the answer is no, because knapsack-pro-cypress calls Cypress internally using node and cypress-rails calls node from within Ruby to build the commands plus bootstrap itself.

Based on this code from launches_cypress.rb, it takes Cypress CLI options in, so --parallel would work.

      command = <<~EXEC
        CYPRESS_BASE_URL="http://#{server.host}:#{server.port}#{config.base_path}" "#{bin}" #{command} --project "#{config.dir}" #{config.cypress_cli_opts}
      EXEC

But using --parallel requires the Cypress dashboard from what I've understood. I'm not certain of this, the last place I used Cypress had another team handle setting up parallelization on a private cloud.

knapsack-pro-cypress accepts supported Cypress CLI options, so off hand, if we were able to pass in a different node module than cypress, i.e. knapsack-pro-cypress, I think this could work.

I see in finds_bin.rb, cypress is hard-coded.

module CypressRails
  class FindsBin
    LOCAL_PATH = "node_modules/.bin/cypress"

    def call(dir = Dir.pwd)
      local_path = Pathname.new(dir).join(LOCAL_PATH)
      if File.exist?(local_path)
        local_path
      else
        "cypress"
      end
    end
  end
end

If an optional node module name could be passed in as an argument (default = "cypress"), then I think this could all work together.

My question turned into solutioning lol. Anyways, thoughts?

For some more context, this is currently how I have us set up to run knapsack or just cypress.

#!/bin/bash
if [ "$KNAPSACK_PRO_TEST_SUITE_TOKEN_CYPRESS" = "" ]; then
  KNAPSACK_PRO_ENDPOINT=https://api-disabled-for-fork.knapsackpro.com \
    KNAPSACK_PRO_MAX_REQUEST_RETRIES=0 \
    KNAPSACK_PRO_TEST_SUITE_TOKEN_CYPRESS=disabled-for-fork \
    npx cypress run # run without parallelization
else
  npx knapsack-pro-cypress # parallelization is available
fi

and Ideally have it something like this

#!/bin/bash
if [ "$KNAPSACK_PRO_TEST_SUITE_TOKEN_CYPRESS" = "" ]; then
  KNAPSACK_PRO_ENDPOINT=https://api-disabled-for-fork.knapsackpro.com \
    KNAPSACK_PRO_MAX_REQUEST_RETRIES=0 \
    KNAPSACK_PRO_TEST_SUITE_TOKEN_CYPRESS=disabled-for-fork \
    npx cypress run # run without parallelization
else
  bundle exec rake cypress:run["knapsack-pro-cypress"] # parallelization is available
fi

Also, I'm happy to contribute to any work this would involve.

@searls
Copy link
Member

searls commented Jan 9, 2021

One thing that would likely work in your case is to not install cypress locally to the project (such that "node_modules/.bin/cypress") did not resolve, and then to put a custom script on your PATH named cypress that calls the thing you want.

I don't think I'd be eager to add an additional option for custom / non-cypress executables

@searls searls closed this as completed Jan 9, 2021
@nickytonline
Copy link
Author

Thanks for chiming in @searls! I'll try out your suggestion.

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

No branches or pull requests

2 participants