Class: TestLauncher::Frameworks::Mochajs::Runner

Inherits:
Base::Runner
  • Object
show all
Defined in:
lib/test_launcher/frameworks/mochajs.rb

Instance Method Summary collapse

Methods inherited from Base::Runner

#initialize, #multiple_examples, #multiple_files, #single_file

Constructor Details

This class inherits a constructor from TestLauncher::Frameworks::Base::Runner

Instance Method Details

#by_line_number(test_case) ⇒ Object



77
78
79
80
81
82
83
# File 'lib/test_launcher/frameworks/mochajs.rb', line 77

def (test_case)
  if test_case.example
    single_example(test_case, exact_match: true)
  else
    single_file(test_case)
  end
end

#multiple_examples_same_file(test_cases) ⇒ Object



89
90
91
92
# File 'lib/test_launcher/frameworks/mochajs.rb', line 89

def multiple_examples_same_file(test_cases)
  test_case = test_cases.first
  single_example(test_case)
end

#multiple_examples_same_root(test_cases) ⇒ Object



94
95
96
# File 'lib/test_launcher/frameworks/mochajs.rb', line 94

def multiple_examples_same_root(test_cases)
  %{cd #{test_cases.first.app_root} && npm run test #{test_cases.map(&:file).join(" ")} -- --grep #{Shellwords.escape(test_cases.first.example)}}
end

#one_or_more_files(test_cases) ⇒ Object



98
99
100
# File 'lib/test_launcher/frameworks/mochajs.rb', line 98

def one_or_more_files(test_cases)
  %{cd #{test_cases.first.app_root} && npm run test #{test_cases.map(&:file).join(" ")}}
end

#single_example(test_case, **_) ⇒ Object



85
86
87
# File 'lib/test_launcher/frameworks/mochajs.rb', line 85

def single_example(test_case, **_)
  multiple_examples_same_root([test_case])
end