Skip to content

Commit 4f93f72

Browse files
author
Xing Han Lu
committed
Add a snapshot build for all tests
1 parent 48110f9 commit 4f93f72

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

tests/test_percy_snapshot.py

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,20 +104,57 @@ def tearDownClass(cls):
104104
if os.environ.get('PERCY_ENABLED', False):
105105
cls.percy_runner.finalize_build()
106106

107+
def run_percy_on(self, dir_name):
107108
# Find the names of all the screenshots
108109
asset_list = os.listdir(os.path.join(
109110
os.path.dirname(__file__),
110-
'screenshots'
111+
'screenshots',
112+
dir_name
111113
))
112114

113115
# Run Percy
114116
for image in asset_list:
115117
if image.endswith('png'):
118+
output_name = image.replace('.png', '')
119+
116120
self.driver.get('http://localhost:8050/{}'.format(image))
117121

118122
WebDriverWait(self.driver, 20).until(
119123
EC.presence_of_element_located((By.ID, image))
120124
)
121125

122-
self.percy_snapshot(name=image)
126+
self.percy_snapshot(
127+
name='{}: {}'.format(dir_name.upper(), output_name)
128+
)
123129
time.sleep(2)
130+
131+
def test_usage(self):
132+
# Create and start the app
133+
app = self.create_app(dir_name='usage')
134+
self.startServer(app)
135+
136+
self.run_percy_on('usage')
137+
138+
def test_elements(self):
139+
app = self.create_app(dir_name='elements')
140+
self.startServer(app)
141+
142+
self.run_percy_on('elements')
143+
144+
def test_layouts(self):
145+
app = self.create_app(dir_name='layouts')
146+
self.startServer(app)
147+
148+
self.run_percy_on('layouts')
149+
150+
def test_style(self):
151+
app = self.create_app(dir_name='style')
152+
self.startServer(app)
153+
154+
self.run_percy_on('style')
155+
156+
def test_interactions(self):
157+
app = self.create_app(dir_name='interactions')
158+
self.startServer(app)
159+
160+
self.run_percy_on('interactions')

0 commit comments

Comments
 (0)