test-recorder 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +1 -1
- data/Gemfile.lock +3 -3
- data/README.md +13 -1
- data/lib/test_recorder/cdp_recorder.rb +17 -21
- data/lib/test_recorder/rails/setup_and_teardown.rb +2 -1
- data/lib/test_recorder/version.rb +1 -1
- data/test-recorder.gemspec +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b7a9be6d6179b7ea6275e1e9b9463817dd0062452ca6b45c95c85dd9a3d8840
|
4
|
+
data.tar.gz: af977f2a4990f75f107210dd50b3f4c755f5efdbc7779e9c070dc480a715e4d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f0faa3366d09f18b142ed4f5c42fa9ae1a7be31c8359eccae8695004920a973188880e0599759fc8b480e4c3e080d3a6985931d5d34fea2e349d36ed4d8005e
|
7
|
+
data.tar.gz: 634c35482c87795803ed7509d5042c357c440e876f03e6969a80501ca7d6e80b8b71292f1d13e9199e1c37dcf72763026b05e4c07fd91851a50162dc6e309ed8
|
data/.github/workflows/ci.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
test-recorder (0.1.
|
4
|
+
test-recorder (0.1.3)
|
5
5
|
activesupport
|
6
|
-
activesupport-testing-metadata
|
7
6
|
selenium-devtools
|
8
7
|
selenium-webdriver (>= 4.0)
|
9
8
|
|
@@ -33,7 +32,7 @@ GEM
|
|
33
32
|
io-console (~> 0.5)
|
34
33
|
rexml (3.2.5)
|
35
34
|
rubyzip (2.3.2)
|
36
|
-
selenium-devtools (0.
|
35
|
+
selenium-devtools (0.100.0)
|
37
36
|
websocket (~> 1.0)
|
38
37
|
selenium-webdriver (4.1.0)
|
39
38
|
childprocess (>= 0.5, < 5.0)
|
@@ -47,6 +46,7 @@ PLATFORMS
|
|
47
46
|
ruby
|
48
47
|
|
49
48
|
DEPENDENCIES
|
49
|
+
activesupport-testing-metadata
|
50
50
|
debug
|
51
51
|
minitest (~> 5.0)
|
52
52
|
rake (~> 12.0)
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Record a video automatically when tests failed. The videos are generated in `tmp/videos` directory.
|
4
4
|
|
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
8
|
|
@@ -54,6 +54,16 @@ require 'test_recorder/rspec'
|
|
54
54
|
|
55
55
|
#### Rails
|
56
56
|
|
57
|
+
##### 1: Install the additional Gem
|
58
|
+
|
59
|
+
Using Bundler, add the following to your Gemfile:
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
gem 'activesupport-testing-metadata', group: :test
|
63
|
+
```
|
64
|
+
|
65
|
+
##### 2. Disable `TestRecorder`, and specified tests with the tag
|
66
|
+
|
57
67
|
```ruby
|
58
68
|
# test/test_helper.rb
|
59
69
|
require 'test_recorder/rails'
|
@@ -70,6 +80,8 @@ end
|
|
70
80
|
|
71
81
|
#### RSpec
|
72
82
|
|
83
|
+
You don't need to install other gems. Only disable `TestRecorder`, and specified tests with the tag.
|
84
|
+
|
73
85
|
```ruby
|
74
86
|
# test/test_helper.rb
|
75
87
|
require 'test_recorder/rspec'
|
@@ -1,10 +1,11 @@
|
|
1
|
+
require "open3"
|
1
2
|
require "fileutils"
|
3
|
+
require "tempfile"
|
2
4
|
|
3
5
|
module TestRecorder
|
4
6
|
class CdpRecorder
|
5
7
|
def initialize(enabled:)
|
6
8
|
@enabled = enabled
|
7
|
-
@tmpdir = nil
|
8
9
|
setup
|
9
10
|
end
|
10
11
|
|
@@ -17,19 +18,20 @@ module TestRecorder
|
|
17
18
|
enabled = @enabled if enabled.nil?
|
18
19
|
return unless enabled
|
19
20
|
|
20
|
-
@
|
21
|
-
|
21
|
+
@tmp_video = Tempfile.open(["testrecorder", ".mp4"])
|
22
|
+
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
|
+
@stdin, @wait_thrs = *Open3.pipeline_w(cmd)
|
24
|
+
@stdin.set_encoding("ASCII-8BIT")
|
22
25
|
|
23
26
|
@page = page
|
24
27
|
@page.driver.browser.devtools.page.enable
|
25
28
|
|
26
29
|
@page.driver.browser.devtools.page.on(:screencast_frame) do |event|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
IO.binwrite("#{File.join(@tmpdir, filename)}", decoded_data)
|
31
|
-
@counter += 1
|
30
|
+
unless @stdin.closed?
|
31
|
+
decoded_data = Base64.decode64(event["data"])
|
32
|
+
@stdin.print(decoded_data)
|
32
33
|
end
|
34
|
+
|
33
35
|
@page.driver.browser.devtools.page.screencast_frame_ack(session_id: event["sessionId"])
|
34
36
|
end
|
35
37
|
|
@@ -37,25 +39,19 @@ module TestRecorder
|
|
37
39
|
end
|
38
40
|
|
39
41
|
def stop_and_discard
|
40
|
-
|
42
|
+
@stdin.close
|
41
43
|
end
|
42
44
|
|
43
45
|
def stop_and_save(filename)
|
44
|
-
return if @
|
46
|
+
return if @page.nil?
|
45
47
|
|
46
|
-
@
|
47
|
-
|
48
|
+
@stdin.close
|
49
|
+
@wait_thrs.each(&:join)
|
48
50
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
-threads 1 #{video_path})
|
53
|
-
system("ffmpeg", *args, exception: true)
|
51
|
+
video_path = File.join(@video_dir, filename)
|
52
|
+
FileUtils.copy(@tmp_video.path, video_path)
|
53
|
+
@tmp_video.close(true)
|
54
54
|
video_path
|
55
|
-
rescue => e
|
56
|
-
$stderr.puts("[TestRecorder] ffmpeg failed: #{e.message}")
|
57
|
-
ensure
|
58
|
-
FileUtils.rm_rf(@tmpdir)
|
59
55
|
end
|
60
56
|
end
|
61
57
|
end
|
@@ -6,7 +6,8 @@ module TestRecorder
|
|
6
6
|
def before_setup
|
7
7
|
|
8
8
|
@cdp_recorder = TestRecorder::CdpRecorder.new(enabled: TestRecorder.enabled?)
|
9
|
-
|
9
|
+
enabled = respond_to?(:metadata) ? metadata[:test_recorder] : nil
|
10
|
+
@cdp_recorder.start(page: page, enabled: enabled)
|
10
11
|
|
11
12
|
super
|
12
13
|
end
|
data/test-recorder.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
spec.add_dependency "activesupport"
|
23
|
-
spec.add_dependency "activesupport-testing-metadata"
|
24
23
|
spec.add_dependency "selenium-webdriver", ">= 4.0"
|
25
24
|
spec.add_dependency "selenium-devtools"
|
25
|
+
spec.add_development_dependency "activesupport-testing-metadata"
|
26
26
|
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.
|
4
|
+
version: 0.1.3
|
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-
|
11
|
+
date: 2022-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -25,41 +25,41 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: selenium-webdriver
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
33
|
+
version: '4.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
40
|
+
version: '4.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name: selenium-
|
42
|
+
name: selenium-devtools
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: activesupport-testing-metadata
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
-
type: :
|
62
|
+
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|