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



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

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



87
88
89
90
# File 'lib/test_launcher/frameworks/mochajs.rb', line 87

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

#multiple_examples_same_root(test_cases) ⇒ Object



92
93
94
# File 'lib/test_launcher/frameworks/mochajs.rb', line 92

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



96
97
98
# File 'lib/test_launcher/frameworks/mochajs.rb', line 96

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



83
84
85
# File 'lib/test_launcher/frameworks/mochajs.rb', line 83

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