test-recorder 0.1.3 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b7a9be6d6179b7ea6275e1e9b9463817dd0062452ca6b45c95c85dd9a3d8840
4
- data.tar.gz: af977f2a4990f75f107210dd50b3f4c755f5efdbc7779e9c070dc480a715e4d1
3
+ metadata.gz: c74ddd16cdffa85784c96e4be8bc549752122364fa729a5cf8cc68fc923d4dc0
4
+ data.tar.gz: 5b9d3ec1a27a641c447ac896a031625153027797a9b5d2a163bdb17f706a88b0
5
5
  SHA512:
6
- metadata.gz: 9f0faa3366d09f18b142ed4f5c42fa9ae1a7be31c8359eccae8695004920a973188880e0599759fc8b480e4c3e080d3a6985931d5d34fea2e349d36ed4d8005e
7
- data.tar.gz: 634c35482c87795803ed7509d5042c357c440e876f03e6969a80501ca7d6e80b8b71292f1d13e9199e1c37dcf72763026b05e4c07fd91851a50162dc6e309ed8
6
+ metadata.gz: 572f1b6775222278e1e036c8c7e692f1991521fbcc30ecab6e44f7e713252670f62a2b88f308ff0eb6467ee6c65db90966f98f3cffd1a8d2e8bf59372b601199
7
+ data.tar.gz: 397223170511f89678bbf2593586929965a12dd6b1c969d328a18cdc26b818717b39173f818210eb3be457b12f0df9d354718cf4175d12eab4d95d697d99b10e
@@ -11,13 +11,13 @@ jobs:
11
11
  cancel-in-progress: true
12
12
 
13
13
  steps:
14
- - uses: actions/checkout@v2
14
+ - uses: actions/checkout@v3
15
15
  - uses: ruby/setup-ruby@v1
16
16
  with:
17
- ruby-version: '3.0.3'
18
- - uses: actions/setup-node@v1
17
+ ruby-version: '3.2'
18
+ - uses: actions/setup-node@v2
19
19
  with:
20
- node-version: '14'
20
+ node-version: '18'
21
21
  - name: Install ffmpeg
22
22
  run: |
23
23
  sudo apt update && sudo apt install ffmpeg
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- test-recorder (0.1.3)
4
+ test-recorder (0.1.5)
5
5
  activesupport
6
6
  selenium-devtools
7
7
  selenium-webdriver (>= 4.0)
@@ -9,36 +9,35 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- activesupport (7.0.1)
12
+ activesupport (7.0.4)
13
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
14
  i18n (>= 1.6, < 2)
15
15
  minitest (>= 5.1)
16
16
  tzinfo (~> 2.0)
17
17
  activesupport-testing-metadata (0.1.0)
18
18
  activesupport (>= 4.0)
19
- childprocess (4.1.0)
20
- concurrent-ruby (1.1.9)
21
- debug (1.4.0)
22
- irb (>= 1.3.6)
23
- reline (>= 0.2.7)
24
- i18n (1.8.11)
19
+ concurrent-ruby (1.1.10)
20
+ debug (1.7.1)
21
+ irb (>= 1.5.0)
22
+ reline (>= 0.3.1)
23
+ i18n (1.12.0)
25
24
  concurrent-ruby (~> 1.0)
26
- io-console (0.5.11)
27
- irb (1.4.1)
25
+ io-console (0.6.0)
26
+ irb (1.6.2)
28
27
  reline (>= 0.3.0)
29
- minitest (5.14.2)
28
+ minitest (5.17.0)
30
29
  rake (12.3.3)
31
- reline (0.3.1)
30
+ reline (0.3.2)
32
31
  io-console (~> 0.5)
33
32
  rexml (3.2.5)
34
33
  rubyzip (2.3.2)
35
- selenium-devtools (0.100.0)
36
- websocket (~> 1.0)
37
- selenium-webdriver (4.1.0)
38
- childprocess (>= 0.5, < 5.0)
34
+ selenium-devtools (0.109.0)
35
+ selenium-webdriver (~> 4.2)
36
+ selenium-webdriver (4.7.1)
39
37
  rexml (~> 3.2, >= 3.2.5)
40
- rubyzip (>= 1.2.2)
41
- tzinfo (2.0.4)
38
+ rubyzip (>= 1.2.2, < 3.0)
39
+ websocket (~> 1.0)
40
+ tzinfo (2.0.5)
42
41
  concurrent-ruby (~> 1.0)
43
42
  websocket (1.2.9)
44
43
 
@@ -53,4 +52,4 @@ DEPENDENCIES
53
52
  test-recorder!
54
53
 
55
54
  BUNDLED WITH
56
- 2.2.32
55
+ 2.4.3
data/README.md CHANGED
@@ -5,6 +5,7 @@ Record a video automatically when tests failed. The videos are generated in `tmp
5
5
  [![Build Status](https://github.com/y-yagi/test-recorder/workflows/CI/badge.svg)](https://github.com/y-yagi/test-recorder/actions)
6
6
  [![Gem Version](https://badge.fury.io/rb/test-recorder.svg)](http://badge.fury.io/rb/test-recorder)
7
7
 
8
+ This gem was inspired by [Record video feature of Playwright](https://playwright.dev/docs/videos).
8
9
 
9
10
  ## Requirements
10
11
 
@@ -6,6 +6,8 @@ module TestRecorder
6
6
  class CdpRecorder
7
7
  def initialize(enabled:)
8
8
  @enabled = enabled
9
+ @started = nil
10
+ @page = nil
9
11
  setup
10
12
  end
11
13
 
@@ -16,9 +18,10 @@ module TestRecorder
16
18
 
17
19
  def start(page:, enabled: nil)
18
20
  enabled = @enabled if enabled.nil?
19
- return unless enabled
21
+ @started = enabled
22
+ return unless @started
20
23
 
21
- @tmp_video = Tempfile.open(["testrecorder", ".mp4"])
24
+ @tmp_video = Tempfile.open(["testrecorder", ".webm"])
22
25
  cmd = "ffmpeg -loglevel quiet -f image2pipe -avioflags direct -fpsprobesize 0 -probesize 32 -analyzeduration 0 -c:v mjpeg -i - -y -an -r 25 -qmin 0 -qmax 50 -crf 8 -deadline realtime -speed 8 -b:v 1M -threads 1 #{@tmp_video.path}"
23
26
  @stdin, @wait_thrs = *Open3.pipeline_w(cmd)
24
27
  @stdin.set_encoding("ASCII-8BIT")
@@ -27,11 +30,8 @@ module TestRecorder
27
30
  @page.driver.browser.devtools.page.enable
28
31
 
29
32
  @page.driver.browser.devtools.page.on(:screencast_frame) do |event|
30
- unless @stdin.closed?
31
- decoded_data = Base64.decode64(event["data"])
32
- @stdin.print(decoded_data)
33
- end
34
-
33
+ decoded_data = Base64.decode64(event["data"])
34
+ @stdin.print(decoded_data) rescue nil
35
35
  @page.driver.browser.devtools.page.screencast_frame_ack(session_id: event["sessionId"])
36
36
  end
37
37
 
@@ -39,18 +39,23 @@ module TestRecorder
39
39
  end
40
40
 
41
41
  def stop_and_discard
42
- @stdin.close
42
+ if @started
43
+ @page.driver.browser.devtools.page.stop_screencast
44
+ @stdin.close
45
+ end
43
46
  end
44
47
 
45
48
  def stop_and_save(filename)
46
- return if @page.nil?
49
+ return "" unless @started
47
50
 
51
+ @page.driver.browser.devtools.page.stop_screencast
48
52
  @stdin.close
49
53
  @wait_thrs.each(&:join)
50
54
 
51
55
  video_path = File.join(@video_dir, filename)
52
56
  FileUtils.copy(@tmp_video.path, video_path)
53
57
  @tmp_video.close(true)
58
+
54
59
  video_path
55
60
  end
56
61
  end
@@ -1,10 +1,7 @@
1
- require "fileutils"
2
-
3
1
  module TestRecorder
4
2
  module Rails
5
3
  module SetupAndTeardown
6
4
  def before_setup
7
-
8
5
  @cdp_recorder = TestRecorder::CdpRecorder.new(enabled: TestRecorder.enabled?)
9
6
  enabled = respond_to?(:metadata) ? metadata[:test_recorder] : nil
10
7
  @cdp_recorder.start(page: page, enabled: enabled)
@@ -16,7 +13,7 @@ module TestRecorder
16
13
  if failures.empty?
17
14
  @cdp_recorder.stop_and_discard
18
15
  else
19
- video_path = @cdp_recorder.stop_and_save("failures_#{self.name}.mp4")
16
+ video_path = @cdp_recorder.stop_and_save("failures_#{self.name}.webm")
20
17
  puts "[Video]: #{video_path}" if File.exist?(video_path)
21
18
  end
22
19
  ensure
@@ -10,7 +10,7 @@ module TestRecorder
10
10
 
11
11
  def after_failed_example(example)
12
12
  if example.exception
13
- video_path = cdp_recorder.stop_and_save("failures_#{method_name(example)}.mp4").to_s
13
+ video_path = cdp_recorder.stop_and_save("failures_#{method_name(example)}.webm").to_s
14
14
  if File.exist?(video_path)
15
15
  example.metadata[:extra_failure_lines] = [example.metadata[:extra_failure_lines], "[Video]: #{video_path}"].flatten
16
16
  end
@@ -1,3 +1,3 @@
1
1
  module TestRecorder
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-recorder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuji Yaginuma
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-04-10 00:00:00.000000000 Z
11
+ date: 2023-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  - !ruby/object:Gem::Version
112
112
  version: '0'
113
113
  requirements: []
114
- rubygems_version: 3.2.32
114
+ rubygems_version: 3.4.1
115
115
  signing_key:
116
116
  specification_version: 4
117
117
  summary: Automatically record videos when tests failed.