Skip to content

Instantly share code, notes, and snippets.

@amkisko
Last active April 22, 2025 11:47
Show Gist options
  • Save amkisko/8fe2f2445cec2ce2e3418f4ff211af2c to your computer and use it in GitHub Desktop.
Save amkisko/8fe2f2445cec2ce2e3418f4ff211af2c to your computer and use it in GitHub Desktop.
Capybara playwright rspec with nodejs 14 version for building assets, nodenv github ci multiple node versions

We are going to fix the situation by using nodenv capabilities with npx wrapper and use env variable to select desired nodejs version whenever we need it, default local version will stay 14, on demand we select 22.

PLAYWRIGHT_COMMAND = "NODENV_VERSION=22.14.0 npx playwright"
Capybara.register_driver(:playspec) do |app|
Capybara::Playwright::Driver.new(
app,
timeout: Capybara.default_max_wait_time,
browser_type: ENV.fetch("BROWSER", "chromium").to_sym, # :chromium (default) or :firefox, :webkit
headless: ENV["HEADFUL"].nil?, # true for headless mode (default), false for headful mode.
playwright_cli_executable_path: PLAYWRIGHT_COMMAND,
debug: ENV["DEBUG"].present?,
logger: Logger.new($stdout)
)
end
- uses: nodenv/actions/setup-nodenv@v3
- name: Install node versions
run: |
if [ ! -d "$HOME/.nodenv/plugins/node-build" ]; then
git clone https://github.com/nodenv/node-build.git ~/.nodenv/plugins/node-build
fi
nodenv install
nodenv install 22.14.0
export PATH="$HOME/.nodenv/bin:$HOME/.nodenv/shims:$PATH"
echo "PATH=$PATH" >> $GITHUB_ENV
npm install -g yarn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment