integration-tests-rails 1.1.3 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 384f4f3272d0ff29fee4b9a2d6bc580eec97967dcfaa195735c24dc147d56a01
4
- data.tar.gz: 8748fcb21a1a74c012254bc9cc1f219c3cf43ab1dfcf5051965e000f7d1893ea
3
+ metadata.gz: 53944743e03bea5bc70d05907ebaf666e5da367c41844a9df967427c41c42860
4
+ data.tar.gz: d144aef9b18271dbb7921bce4e2718072aa9f685b727ebb7907aa13d75c29694
5
5
  SHA512:
6
- metadata.gz: 9e97a327ac819b6fd3155ea5366e959119a25305e6f5db0dbf994bfeaf1be26b621f6d22d5987708f272bca15672a9c9f0e13efdde1c41590c5af3724ca07f05
7
- data.tar.gz: 99848ce892f5abc64e4282d02f2e360e370e2b1c0495e2d470aed7882a6b0bf0b60aea227e0cc9a24577be30c9bfb224730e37329f1be828443d6c456a5ce9b5
6
+ metadata.gz: 0fc048144a72cbef17015e994d933efdedec5f7ccbc573470514eb722fac65a1df6166bde2b87a24cdacd3cb8d11bfee6aa8cc36ecd5143ff5da72219b14da06
7
+ data.tar.gz: ee70f5ac6184b97c2c8e637313fe6fc1d6ecd6ee6c4219e9e9bacc1712d5c2b3a2b108bcb33792d29ba4d7413e9a6e3ec0d5c2fe42ac3b6b64f768a7c29c0b8d
data/README.md CHANGED
@@ -62,7 +62,9 @@ The `IntegrationTestsRails.setup` method accepts an optional block for further c
62
62
 
63
63
  ```ruby
64
64
  IntegrationTestsRails.setup do |config|
65
+ config.auto_retry = false # Whether to automatically wrap all examples inside retry_on_fail block.
65
66
  config.chrome_url = nil # Used for remote Chrome instances. Needs remote to be true.
67
+ config.js_coverage = true # Whether to enable JavaScript coverage using Istanbul.
66
68
  config.max_server_retries = 1000 # Before running the tests, Cuprite starts a server to communicate with Chrome. This sets the maximum number of retries to connect to that server.
67
69
  config.puma_threads = '1:1' # Number of threads for the Puma server used by Cuprite.
68
70
  config.remote = false # Whether to use a remote Chrome instance.
@@ -252,9 +254,23 @@ retry_on_fail(retry_attempts: 3, retry_sleep_duration: 1, capture_exceptions: [S
252
254
  end
253
255
  ```
254
256
 
257
+ ### Auto Retry
258
+
259
+ If you want to automatically retry all examples in a test suite without having to wrap them in `retry_on_fail`, you can set the `auto_retry` configuration option to `true`. This will automatically wrap all examples in a `retry_on_fail` block with the configured number of retries, exceptions to capture and sleep duration between retries.
260
+
261
+ It is possible to pass custom arguments with `auto_retry` enabled through example metadata:
262
+
263
+ ```ruby
264
+ it 'is a flaky test', auto_retry: { retry_attempts: 3, retry_sleep_duration: 2, capture_exceptions: [StandardError] } do
265
+ expect(page).to have_css('div#popover', visible: :visible, wait: 8)
266
+ end
267
+ ```
268
+
269
+ If no metadata is passed, it will use the default configuration values.
270
+
255
271
  ## JavaScript Coverage Reports
256
272
 
257
- After the tests (successful, failed or cancelled), coverage reports will be generated in `coverage/javascript` by default.
273
+ After the tests (successful, failed or cancelled), coverage reports will be generated in `coverage/javascript` by default. This can be disabled in the configuration by setting `js_coverage` to `false`. Be sure to uninstall Istanbul packages through the rake task `rake integration_tests_rails:istanbul:uninstall` if you do not need this feature.
258
274
 
259
275
  ## Example Setups
260
276
 
@@ -43,6 +43,15 @@ module IntegrationTestsRails
43
43
  IntegrationTestsRails::Capybara::Util.ensure_server_ready(self)
44
44
  end
45
45
 
46
+ config.around(:each, type: :feature) do |example|
47
+ if IntegrationTestsRails.configuration.auto_retry
48
+ kwargs = example.metadata.fetch(:auto_retry, {})
49
+ retry_on_fail(**kwargs) { example.run }
50
+ else
51
+ example.run
52
+ end
53
+ end
54
+
46
55
  if IntegrationTestsRails.configuration.experimental_features
47
56
  config.include(Helper, type: :feature, unit: true)
48
57
  end
@@ -37,16 +37,18 @@ module IntegrationTestsRails
37
37
  </html>
38
38
  HTML
39
39
 
40
- attr_accessor :source_dir, :output_dir, :backup_dir, :coverage_path, :wait_time, :remote,
41
- :chrome_url, :tests_page_html, :window_size, :max_server_retries,
42
- :verbose, :timeout, :server_host, :server_port, :puma_threads, :experimental_features,
40
+ attr_accessor :source_dir, :output_dir, :backup_dir, :coverage_path, :wait_time, :remote, :chrome_url, :window_size,
41
+ :tests_page_html, :max_server_retries, :verbose, :js_coverage, :auto_retry,
42
+ :timeout, :server_host, :server_port, :puma_threads, :experimental_features,
43
43
  :retry_attempts, :retry_sleep_duration, :retry_capture_exceptions
44
44
 
45
- def initialize
45
+ def initialize # rubocop:disable Metrics/MethodLength
46
+ @auto_retry = false
46
47
  @backup_dir = 'tmp/js_backup'
47
48
  @chrome_url = nil
48
49
  @coverage_path = 'coverage/nyc'
49
50
  @experimental_features = false
51
+ @js_coverage = true
50
52
  @max_server_retries = 1000
51
53
  @output_dir = 'tmp/instrumented_js'
52
54
  @puma_threads = '1:1'
@@ -9,14 +9,22 @@ module IntegrationTestsRails
9
9
  module Istanbul
10
10
  class << self
11
11
  def setup
12
- Util.configure_rspec
12
+ if IntegrationTestsRails.configuration.js_coverage
13
+ Util.configure_rspec
14
+ else
15
+ Util.log('JS coverage is disabled, skipping Istanbul setup.')
16
+ end
13
17
  end
14
18
  end
15
19
 
16
20
  # Ensure cleanup at exit, either success, failure or cancellation.
17
21
  at_exit do
18
- Collector.generate_report
19
- Collector.restore_original_files
22
+ if IntegrationTestsRails.configuration.js_coverage
23
+ Collector.generate_report
24
+ Collector.restore_original_files
25
+ else
26
+ Util.log('JS coverage is disabled, skipping Istanbul cleanup.')
27
+ end
20
28
  rescue StandardError => e
21
29
  warn "Istanbul cleanup failed: #{e.message}"
22
30
  end
@@ -37,6 +37,35 @@ module IntegrationTestsRails
37
37
 
38
38
  puts 'Integration tests environment setup complete.'
39
39
  end
40
+
41
+ namespace :istanbul do
42
+ desc 'Remove Istanbul installation.'
43
+ task uninstall: :environment do
44
+ puts 'Removing Istanbul...'
45
+ system('yarn remove istanbul-lib-instrument istanbul-lib-coverage istanbul-lib-report istanbul-reports')
46
+ puts 'Istanbul removed. '
47
+
48
+ if File.exist?('.gitignore')
49
+ content = File.read('.gitignore')
50
+ new_content = content.dup
51
+ lines_to_remove = ['tmp/instrumented_js/', 'tmp/js_backup/']
52
+ lines_to_remove.each do |line|
53
+ if content.include?(line)
54
+ new_content = new_content.gsub("#{line}\n", '')
55
+ puts "Removed '#{line}' from .gitignore."
56
+ else
57
+ puts "'#{line}' not found in .gitignore. Skipping."
58
+ end
59
+ end
60
+ if new_content == content
61
+ puts 'No changes made to .gitignore.'
62
+ else
63
+ File.write('.gitignore', new_content)
64
+ puts '.gitignore updated.'
65
+ end
66
+ end
67
+ end
68
+ end
40
69
  end
41
70
  end
42
71
  # rubocop:enable Metrics/BlockLength
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IntegrationTestsRails
4
- VERSION = '1.1.3'
4
+ VERSION = '1.1.5'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: integration-tests-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tien