-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
root.ts
38 lines (30 loc) · 817 Bytes
/
root.ts
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
import _ from 'lodash'
export default (Commands, Cypress, cy, state) => {
Commands.addAll({
// TODO: any -> Partial<Cypress.Loggable & Cypress.Timeoutable>
root (options: any = {}) {
const userOptions = options
options = _.defaults({}, userOptions, { log: true })
if (options.log !== false) {
options._log = Cypress.log({
message: '',
timeout: options.timeout,
})
}
const log = ($el) => {
if (options.log) {
options._log.set({ $el })
}
return $el
}
const withinSubject = state('withinSubject')
if (withinSubject) {
return log(withinSubject)
}
return cy.now('get', 'html', {
log: false,
timeout: options.timeout,
}).then(log)
},
})
}