/
index.js
45 lines (40 loc) · 1.04 KB
/
index.js
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
/// <reference path='./index.d.ts' />
/*
USAGE: in `support/index.(js|ts)`
import '@rckller/cypress-redux'
*/
Cypress.Commands.add('store', () => {
return cy
.log('Redux - Store')
.window({ log: false })
.its('store')
})
Cypress.Commands.add('getState', (node) => {
return node
? cy
.log(`Redux - state[${node}]`)
.window({ log: false })
.its('store')
.invoke('getState')
.its(node.toString())
: cy
.log('Redux - State')
.window({ log: false })
.its('store')
.invoke('getState')
})
Cypress.Commands.add('dispatch', (action = { type: 'NO_OP' }) => {
const { type, ...params } = action
return cy
.log(`Redux - Dispatch: ${type}`, params)
.window({ log: false })
.its('store')
.invoke('dispatch', action)
})
Cypress.Commands.add('subscribe', (callback = (...args) => console.warn('CB:', args)) => {
return cy
.log('Redux - Subscribe')
.window({ log: false })
.its('store')
.invoke('subscribe', callback)
})