Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix(test): Launch a webserver for e2e tests, if it's not running yet #1767

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,19 @@ namespace :test do


desc 'Run e2e test suite (single run)'
task :e2e, :browsers, :misc_options do |t, args|
task :e2e, [:browsers, :misc_options] => ['docs', 'e2e:server'] do |t, args|
start_testacular('testacular-e2e.conf.js', true, args[:browsers], args[:misc_options])
end

namespace :e2e do
desc 'Check for & launch a webserver'
task 'server' do
testacular_proxy_port_number = 8000
unless server?(testacular_proxy_port_number)
system "node lib/nodeserver/server.js #{testacular_proxy_port_number} &"
end
end
end
end


Expand Down Expand Up @@ -335,3 +345,12 @@ def start_testacular(config, singleRun, browsers, misc_options)
"#{'--browsers=' + browsers.gsub('+', ',') if browsers} " +
"#{(misc_options || '').gsub('+', ',')}"
end

def server?(port)
require 'socket'
s = TCPSocket.open('localhost', port)
rescue => e
return nil
ensure
s && s.close
end