Skip to content

Commit c8d3d73

Browse files
committed
Fixes and refinements
1 parent a02e4ce commit c8d3d73

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

lib/rules/assertion-before-screenshot.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@
55

66
'use strict'
77

8+
const assertionCommands = [
9+
// assertions
10+
'should',
11+
'and',
12+
'contains',
13+
14+
// not an assertion, but unlikely to require waiting for render
15+
'scrollIntoView',
16+
'scrollTo',
17+
];
18+
819
module.exports = {
920
meta: {
1021
docs: {
@@ -30,11 +41,11 @@ module.exports = {
3041

3142
function isRootCypress(node) {
3243
while(node.type === 'CallExpression') {
33-
if (node.callee.type === 'MemberExpression' &&
34-
node.callee.object.type === 'Identifier' &&
44+
if (node.callee.type !== 'MemberExpression') return false
45+
if (node.callee.object.type === 'Identifier' &&
3546
node.callee.object.name === 'cy') {
36-
return true
37-
}
47+
return true
48+
}
3849
node = node.callee.object
3950
}
4051
return false
@@ -92,6 +103,5 @@ function getPreviousCypressCommand(node) {
92103

93104
function isPreviousAnAssertion (node) {
94105
const previousCypressCommand = getPreviousCypressCommand(node)
95-
return previousCypressCommand === 'get' ||
96-
previousCypressCommand === 'should'
106+
return assertionCommands.indexOf(previousCypressCommand) >= 0
97107
}

0 commit comments

Comments
 (0)