-
Notifications
You must be signed in to change notification settings - Fork 16
/
phantomcss.node.txt
114 lines (87 loc) · 6.97 KB
/
phantomcss.node.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
PHANTOMCSS
ALTERNATIVES ==> #See argus-eyes
VERSION ==> #1.0.0
#Image diff testing:
# - inside a Casper script, take a screenshot
# - compare with previously taken screenshots
PHANTOMCSS.init|update(CONF) #Initialize
CONF.casper #CASPER
CONF.libraryRoot #Should point to node_modules/phantomcss/ (def: '.')
/=+===============================+=\
/ : : \
)==: SCREENSHOT :==(
\ :_______________________________: /
\=+===============================+=/
PHANTOMCSS.screenshot(OBJ) #Takes the screenshot and place it in the correct folders.
#Must be inside CASPER script.
#OBJ is { 'FILENAME': OBJ2|'SELECTOR' }, with OBJ2:
# - selector 'SELECTOR' or OBJ3: top|left|width|height NUM
# - ignore 'SELECTOR':
# - set DOM element to visibility: hidden
# - can use CONF.hideElements, added to any "ignore"
# - wait NUM (in ms):
# - wait before taking screenshot
# - def: 250
PHANTOMCSS.screenshot
('SELECTOR'|OBJ3,'FILENAME'[,NUM])#Shortcut
CONF.screenshotRoot #'DIR' containing baseline screenshots, i.e. first ones:
# - def: './screenshots'
# - using CONF.rebase true, creates new baseline screenshots.
CONF.comparisonResultRoot #'DIR':
# - containing last screenshots
# - FILE.diff.png is the screenshot
# - FILE.png is the baseline screenshot it was compared against
# - def: same as screenshotRoot
# - using CONF.cleanupComparisonImages true, cleans up directory at each compareAll(),
# unless CONF.onComplete has been defined
CONF.addIteratorToImage #BOOL. If true (def), add counter to filename
CONF.prefixCount #BOOL: put count number in filename at the end (false, def) or the beginning (true)
CONF.baseline|diffImage|
failureImageSuffix #STR (def: '', '.diff', '.fail')
CONF.fileNameGetter('DIR', 'FILE')
->'PATH.png' #Custom output filename
PHANTOMCSS.turnOffAnimations() #Injects <style> with '* { transition: none !important; animation: none !important }'
REPORTING ==> #Def: use CASPER.test.pass|fail|info() and console.log()
CONF.onNewImage(OBJ) #Fired when screenshot is taken.
#OBJ:
# - filename 'FILE'
/=+===============================+=\
/ : : \
)==: COMPARISON :==(
\ :_______________________________: /
\=+===============================+=/
PHANTOMCSS.compareFiles #Compare images using resemble.js
('FILE.png', 'FILE.diff.png') #If differences, put difference file as FILE.fail.png in FAILURE_DIR and in FILE.diff.png's directory
#Must use PHANTOMCSS.waitForTests(VAL) on return VAL (must not be done for other compareAll())
PHANTOMCSS.compareAll(REGEXP #Use compareFiles('FILE.png', 'FILE.diff.png') on all 'FILE.diff.png'_ARR:
[, 'FILE.diff.png'_ARR][,REGEXP2])# - def: all of them
# - REGEXP[2] whitelists|blacklists files
PHANTOMCSS.compareSession() #Same as compareAll(false)
PHANTOMCSS.compareExplicit
('FILE.diff.png'_ARR) #Same as compareAll(false, 'FILE.diff.png'_ARR)
PHANTOMCSS.compareMatched
(REGEXP2, REGEXP) #Same as compareAll(REGEXP, false, REGEXP2)
CONF.failedComparisonsRoot #'FAILURE_DIR' containing difference comparison images (def: './failures')
CONF.mismatchTolerance #FLOAT (0-1) (def: 0.05): below this, do not create comparison images
CONF.outputSettings #OBJ. See Resemble.js (def: null)
#Will always use ignoreAntialiasing() mode
CONF.addLabelToFailedImage #BOOL. If true (def), add filename as title on the comparison image
CONF.waitTimeout #How long to wait for images to load (def: 1 minute)
PHANTOMCSS.getExitStatus()->NUM #Number of difference images produced.
REPORTING ==> #Fired on compare*()
#Def: use CASPER.test.pass|fail|info() and console.log()
CONF.onPass(OBJ) #When no differences. OBJ:
# - filename 'FILE'
# - success true
CONF.onFail(OBJ) #Def:
#OBJ:
# - filename 'FILE'
# - fail true
# - failFile 'FILE'
# - mismatch FLOAT
CONF.onTimeout() #Fired when images took too long to load
#Same OBJ as onFail(), without mismatch
CONF.onComplete(OBJ_ARR, NUM,NUM2)#OBJ_ARR: any possible option of onPass|Fail|Timeout|NewImage()
#NUM are fails, NUM2 errors