br-dionysus 1.7.7 → 1.7.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -13
- package/attributes.json +1 -1
- package/build/doc.config.ts +1 -1
- package/build/lib.config.ts +1 -1
- package/cypress/component/MInputNumber.cy.ts +38 -0
- package/cypress/component/MSelect.cy.ts +46 -0
- package/cypress/component/MSelectV2.cy.ts +46 -0
- package/cypress/e2e/1-getting-started/todo.cy.js +143 -0
- package/cypress/e2e/2-advanced-examples/actions.cy.js +321 -0
- package/cypress/e2e/2-advanced-examples/aliasing.cy.js +39 -0
- package/cypress/e2e/2-advanced-examples/assertions.cy.js +176 -0
- package/cypress/e2e/2-advanced-examples/connectors.cy.js +98 -0
- package/cypress/e2e/2-advanced-examples/cookies.cy.js +118 -0
- package/cypress/e2e/2-advanced-examples/cypress_api.cy.js +185 -0
- package/cypress/e2e/2-advanced-examples/files.cy.js +85 -0
- package/cypress/e2e/2-advanced-examples/location.cy.js +32 -0
- package/cypress/e2e/2-advanced-examples/misc.cy.js +90 -0
- package/cypress/e2e/2-advanced-examples/navigation.cy.js +55 -0
- package/cypress/e2e/2-advanced-examples/network_requests.cy.js +163 -0
- package/cypress/e2e/2-advanced-examples/querying.cy.js +114 -0
- package/cypress/e2e/2-advanced-examples/spies_stubs_clocks.cy.js +204 -0
- package/cypress/e2e/2-advanced-examples/storage.cy.js +117 -0
- package/cypress/e2e/2-advanced-examples/traversal.cy.js +121 -0
- package/cypress/e2e/2-advanced-examples/utilities.cy.js +107 -0
- package/cypress/e2e/2-advanced-examples/viewport.cy.js +58 -0
- package/cypress/e2e/2-advanced-examples/waiting.cy.js +30 -0
- package/cypress/e2e/2-advanced-examples/window.cy.js +22 -0
- package/cypress/e2e/spec.cy.ts +5 -0
- package/cypress/e2e/toolCheckType.cy.ts +37 -0
- package/cypress/e2e/toolCompareStructures.cy.ts +19 -0
- package/cypress/e2e/toolCreateHash.cy.ts +7 -0
- package/cypress/e2e/toolMoneyFormat.cy.ts +46 -0
- package/cypress/fixtures/example.json +5 -0
- package/cypress/support/commands.ts +37 -0
- package/cypress/support/component-index.html +12 -0
- package/cypress/support/component.ts +39 -0
- package/cypress/support/e2e.ts +20 -0
- package/cypress/types.d.ts +1 -0
- package/cypress.config.ts +16 -0
- package/dist/br-dionysus.es.js +2774 -2739
- package/dist/br-dionysus.umd.js +7 -7
- package/dist/cypress.config.d.ts +3 -0
- package/dist/index.css +1 -1
- package/dist/packages/MSelectV2/src/MSelectV2.vue.d.ts +8 -2
- package/dist/packages/SkinConfig/src/SkinConfig.vue.d.ts +1 -1
- package/dist/packages/Tool/checkType/checkType.d.ts +7 -0
- package/dist/packages/Tool/compareStructures/compareStructures.d.ts +10 -0
- package/dist/packages/Tool/createHash/createHash.d.ts +7 -0
- package/dist/packages/index.d.ts +6 -2
- package/dist/vite.config.d.ts +2 -0
- package/package.json +7 -3
- package/packages/Hook/useRemainingSpace/demo.vue +0 -1
- package/packages/Hook/useTableConfig/demo.vue +1 -1
- package/packages/MDialog/src/MDialog.vue +2 -8
- package/packages/MInline/src/MInline.vue +1 -11
- package/packages/MInputNumber/src/MInputNumber.vue +3 -5
- package/packages/MSelectV2/docs/demo.vue +1 -1
- package/packages/MSelectV2/src/MSelectV2.vue +10 -6
- package/packages/MTable/src/MTable.vue +2 -2
- package/packages/MTableColumn/src/MTableColumn.vue +49 -6
- package/packages/MTableColumnSet/src/MTableColumnSet.vue +1 -1
- package/packages/SkinConfig/src/SkinConfig.vue +2 -1
- package/packages/SkinConfig/src/useSkin.ts +5 -2
- package/packages/Tool/checkType/README.md +17 -0
- package/packages/Tool/checkType/checkType.ts +14 -0
- package/packages/Tool/compareStructures/README.md +16 -0
- package/packages/Tool/createHash/README.md +7 -0
- package/packages/Tool/moneyFormat/README.md +13 -12
- package/packages/Tool/moneyFormat/moneyFormat.ts +35 -2
- package/packages/index.ts +8 -2
- package/src/cypress-augmentation.d.ts +9 -0
- package/tags.json +1 -1
- package/{build/base.config.ts → vite.config.ts} +3 -3
- package/web-types.json +1 -1
- package/tool/checkType.ts +0 -15
- /package/{tool → packages/Tool/compareStructures}/compareStructures.ts +0 -0
- /package/{tool → packages/Tool/createHash}/createHash.ts +0 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
|
|
3
|
+
context('Cookies', () => {
|
|
4
|
+
beforeEach(() => {
|
|
5
|
+
Cypress.Cookies.debug(true)
|
|
6
|
+
|
|
7
|
+
cy.visit('https://example.cypress.io/commands/cookies')
|
|
8
|
+
|
|
9
|
+
// clear cookies again after visiting to remove
|
|
10
|
+
// any 3rd party cookies picked up such as cloudflare
|
|
11
|
+
cy.clearCookies()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('cy.getCookie() - get a browser cookie', () => {
|
|
15
|
+
// https://on.cypress.io/getcookie
|
|
16
|
+
cy.get('#getCookie .set-a-cookie').click()
|
|
17
|
+
|
|
18
|
+
// cy.getCookie() yields a cookie object
|
|
19
|
+
cy.getCookie('token').should('have.property', 'value', '123ABC')
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it('cy.getCookies() - get browser cookies for the current domain', () => {
|
|
23
|
+
// https://on.cypress.io/getcookies
|
|
24
|
+
cy.getCookies().should('be.empty')
|
|
25
|
+
|
|
26
|
+
cy.get('#getCookies .set-a-cookie').click()
|
|
27
|
+
|
|
28
|
+
// cy.getCookies() yields an array of cookies
|
|
29
|
+
cy.getCookies().should('have.length', 1).should((cookies) => {
|
|
30
|
+
// each cookie has these properties
|
|
31
|
+
expect(cookies[0]).to.have.property('name', 'token')
|
|
32
|
+
expect(cookies[0]).to.have.property('value', '123ABC')
|
|
33
|
+
expect(cookies[0]).to.have.property('httpOnly', false)
|
|
34
|
+
expect(cookies[0]).to.have.property('secure', false)
|
|
35
|
+
expect(cookies[0]).to.have.property('domain')
|
|
36
|
+
expect(cookies[0]).to.have.property('path')
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('cy.getAllCookies() - get all browser cookies', () => {
|
|
41
|
+
// https://on.cypress.io/getallcookies
|
|
42
|
+
cy.getAllCookies().should('be.empty')
|
|
43
|
+
|
|
44
|
+
cy.setCookie('key', 'value')
|
|
45
|
+
cy.setCookie('key', 'value', { domain: '.example.com' })
|
|
46
|
+
|
|
47
|
+
// cy.getAllCookies() yields an array of cookies
|
|
48
|
+
cy.getAllCookies().should('have.length', 2).should((cookies) => {
|
|
49
|
+
// each cookie has these properties
|
|
50
|
+
expect(cookies[0]).to.have.property('name', 'key')
|
|
51
|
+
expect(cookies[0]).to.have.property('value', 'value')
|
|
52
|
+
expect(cookies[0]).to.have.property('httpOnly', false)
|
|
53
|
+
expect(cookies[0]).to.have.property('secure', false)
|
|
54
|
+
expect(cookies[0]).to.have.property('domain')
|
|
55
|
+
expect(cookies[0]).to.have.property('path')
|
|
56
|
+
|
|
57
|
+
expect(cookies[1]).to.have.property('name', 'key')
|
|
58
|
+
expect(cookies[1]).to.have.property('value', 'value')
|
|
59
|
+
expect(cookies[1]).to.have.property('httpOnly', false)
|
|
60
|
+
expect(cookies[1]).to.have.property('secure', false)
|
|
61
|
+
expect(cookies[1]).to.have.property('domain', '.example.com')
|
|
62
|
+
expect(cookies[1]).to.have.property('path')
|
|
63
|
+
})
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
it('cy.setCookie() - set a browser cookie', () => {
|
|
67
|
+
// https://on.cypress.io/setcookie
|
|
68
|
+
cy.getCookies().should('be.empty')
|
|
69
|
+
|
|
70
|
+
cy.setCookie('foo', 'bar')
|
|
71
|
+
|
|
72
|
+
// cy.getCookie() yields a cookie object
|
|
73
|
+
cy.getCookie('foo').should('have.property', 'value', 'bar')
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
it('cy.clearCookie() - clear a browser cookie', () => {
|
|
77
|
+
// https://on.cypress.io/clearcookie
|
|
78
|
+
cy.getCookie('token').should('be.null')
|
|
79
|
+
|
|
80
|
+
cy.get('#clearCookie .set-a-cookie').click()
|
|
81
|
+
|
|
82
|
+
cy.getCookie('token').should('have.property', 'value', '123ABC')
|
|
83
|
+
|
|
84
|
+
// cy.clearCookies() yields null
|
|
85
|
+
cy.clearCookie('token')
|
|
86
|
+
|
|
87
|
+
cy.getCookie('token').should('be.null')
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
it('cy.clearCookies() - clear browser cookies for the current domain', () => {
|
|
91
|
+
// https://on.cypress.io/clearcookies
|
|
92
|
+
cy.getCookies().should('be.empty')
|
|
93
|
+
|
|
94
|
+
cy.get('#clearCookies .set-a-cookie').click()
|
|
95
|
+
|
|
96
|
+
cy.getCookies().should('have.length', 1)
|
|
97
|
+
|
|
98
|
+
// cy.clearCookies() yields null
|
|
99
|
+
cy.clearCookies()
|
|
100
|
+
|
|
101
|
+
cy.getCookies().should('be.empty')
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
it('cy.clearAllCookies() - clear all browser cookies', () => {
|
|
105
|
+
// https://on.cypress.io/clearallcookies
|
|
106
|
+
cy.getAllCookies().should('be.empty')
|
|
107
|
+
|
|
108
|
+
cy.setCookie('key', 'value')
|
|
109
|
+
cy.setCookie('key', 'value', { domain: '.example.com' })
|
|
110
|
+
|
|
111
|
+
cy.getAllCookies().should('have.length', 2)
|
|
112
|
+
|
|
113
|
+
// cy.clearAllCookies() yields null
|
|
114
|
+
cy.clearAllCookies()
|
|
115
|
+
|
|
116
|
+
cy.getAllCookies().should('be.empty')
|
|
117
|
+
})
|
|
118
|
+
})
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
|
|
3
|
+
context('Cypress APIs', () => {
|
|
4
|
+
|
|
5
|
+
context('Cypress.Commands', () => {
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
cy.visit('https://example.cypress.io/cypress-api')
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
// https://on.cypress.io/custom-commands
|
|
11
|
+
|
|
12
|
+
it('.add() - create a custom command', () => {
|
|
13
|
+
Cypress.Commands.add('console', {
|
|
14
|
+
prevSubject: true,
|
|
15
|
+
}, (subject, method) => {
|
|
16
|
+
// the previous subject is automatically received
|
|
17
|
+
// and the commands arguments are shifted
|
|
18
|
+
|
|
19
|
+
// allow us to change the console method used
|
|
20
|
+
method = method || 'log'
|
|
21
|
+
|
|
22
|
+
// log the subject to the console
|
|
23
|
+
console[method]('The subject is', subject)
|
|
24
|
+
|
|
25
|
+
// whatever we return becomes the new subject
|
|
26
|
+
// we don't want to change the subject so
|
|
27
|
+
// we return whatever was passed in
|
|
28
|
+
return subject
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
cy.get('button').console('info').then(($button) => {
|
|
32
|
+
// subject is still $button
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
context('Cypress.Cookies', () => {
|
|
38
|
+
beforeEach(() => {
|
|
39
|
+
cy.visit('https://example.cypress.io/cypress-api')
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
// https://on.cypress.io/cookies
|
|
43
|
+
it('.debug() - enable or disable debugging', () => {
|
|
44
|
+
Cypress.Cookies.debug(true)
|
|
45
|
+
|
|
46
|
+
// Cypress will now log in the console when
|
|
47
|
+
// cookies are set or cleared
|
|
48
|
+
cy.setCookie('fakeCookie', '123ABC')
|
|
49
|
+
cy.clearCookie('fakeCookie')
|
|
50
|
+
cy.setCookie('fakeCookie', '123ABC')
|
|
51
|
+
cy.clearCookie('fakeCookie')
|
|
52
|
+
cy.setCookie('fakeCookie', '123ABC')
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
context('Cypress.arch', () => {
|
|
57
|
+
beforeEach(() => {
|
|
58
|
+
cy.visit('https://example.cypress.io/cypress-api')
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it('Get CPU architecture name of underlying OS', () => {
|
|
62
|
+
// https://on.cypress.io/arch
|
|
63
|
+
expect(Cypress.arch).to.exist
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
context('Cypress.config()', () => {
|
|
68
|
+
beforeEach(() => {
|
|
69
|
+
cy.visit('https://example.cypress.io/cypress-api')
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it('Get and set configuration options', () => {
|
|
73
|
+
// https://on.cypress.io/config
|
|
74
|
+
let myConfig = Cypress.config()
|
|
75
|
+
|
|
76
|
+
expect(myConfig).to.have.property('animationDistanceThreshold', 5)
|
|
77
|
+
expect(myConfig).to.have.property('baseUrl', null)
|
|
78
|
+
expect(myConfig).to.have.property('defaultCommandTimeout', 4000)
|
|
79
|
+
expect(myConfig).to.have.property('requestTimeout', 5000)
|
|
80
|
+
expect(myConfig).to.have.property('responseTimeout', 30000)
|
|
81
|
+
expect(myConfig).to.have.property('viewportHeight', 660)
|
|
82
|
+
expect(myConfig).to.have.property('viewportWidth', 1000)
|
|
83
|
+
expect(myConfig).to.have.property('pageLoadTimeout', 60000)
|
|
84
|
+
expect(myConfig).to.have.property('waitForAnimations', true)
|
|
85
|
+
|
|
86
|
+
expect(Cypress.config('pageLoadTimeout')).to.eq(60000)
|
|
87
|
+
|
|
88
|
+
// this will change the config for the rest of your tests!
|
|
89
|
+
Cypress.config('pageLoadTimeout', 20000)
|
|
90
|
+
|
|
91
|
+
expect(Cypress.config('pageLoadTimeout')).to.eq(20000)
|
|
92
|
+
|
|
93
|
+
Cypress.config('pageLoadTimeout', 60000)
|
|
94
|
+
})
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
context('Cypress.dom', () => {
|
|
98
|
+
beforeEach(() => {
|
|
99
|
+
cy.visit('https://example.cypress.io/cypress-api')
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
// https://on.cypress.io/dom
|
|
103
|
+
it('.isHidden() - determine if a DOM element is hidden', () => {
|
|
104
|
+
let hiddenP = Cypress.$('.dom-p p.hidden').get(0)
|
|
105
|
+
let visibleP = Cypress.$('.dom-p p.visible').get(0)
|
|
106
|
+
|
|
107
|
+
// our first paragraph has css class 'hidden'
|
|
108
|
+
expect(Cypress.dom.isHidden(hiddenP)).to.be.true
|
|
109
|
+
expect(Cypress.dom.isHidden(visibleP)).to.be.false
|
|
110
|
+
})
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
context('Cypress.env()', () => {
|
|
114
|
+
beforeEach(() => {
|
|
115
|
+
cy.visit('https://example.cypress.io/cypress-api')
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
// We can set environment variables for highly dynamic values
|
|
119
|
+
|
|
120
|
+
// https://on.cypress.io/environment-variables
|
|
121
|
+
it('Get environment variables', () => {
|
|
122
|
+
// https://on.cypress.io/env
|
|
123
|
+
// set multiple environment variables
|
|
124
|
+
Cypress.env({
|
|
125
|
+
host: 'veronica.dev.local',
|
|
126
|
+
api_server: 'http://localhost:8888/v1/',
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
// get environment variable
|
|
130
|
+
expect(Cypress.env('host')).to.eq('veronica.dev.local')
|
|
131
|
+
|
|
132
|
+
// set environment variable
|
|
133
|
+
Cypress.env('api_server', 'http://localhost:8888/v2/')
|
|
134
|
+
expect(Cypress.env('api_server')).to.eq('http://localhost:8888/v2/')
|
|
135
|
+
|
|
136
|
+
// get all environment variable
|
|
137
|
+
expect(Cypress.env()).to.have.property('host', 'veronica.dev.local')
|
|
138
|
+
expect(Cypress.env()).to.have.property('api_server', 'http://localhost:8888/v2/')
|
|
139
|
+
})
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
context('Cypress.log', () => {
|
|
143
|
+
beforeEach(() => {
|
|
144
|
+
cy.visit('https://example.cypress.io/cypress-api')
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
it('Control what is printed to the Command Log', () => {
|
|
148
|
+
// https://on.cypress.io/cypress-log
|
|
149
|
+
})
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
context('Cypress.platform', () => {
|
|
153
|
+
beforeEach(() => {
|
|
154
|
+
cy.visit('https://example.cypress.io/cypress-api')
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
it('Get underlying OS name', () => {
|
|
158
|
+
// https://on.cypress.io/platform
|
|
159
|
+
expect(Cypress.platform).to.be.exist
|
|
160
|
+
})
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
context('Cypress.version', () => {
|
|
164
|
+
beforeEach(() => {
|
|
165
|
+
cy.visit('https://example.cypress.io/cypress-api')
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
it('Get current version of Cypress being run', () => {
|
|
169
|
+
// https://on.cypress.io/version
|
|
170
|
+
expect(Cypress.version).to.be.exist
|
|
171
|
+
})
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
context('Cypress.spec', () => {
|
|
175
|
+
beforeEach(() => {
|
|
176
|
+
cy.visit('https://example.cypress.io/cypress-api')
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
it('Get current spec information', () => {
|
|
180
|
+
// https://on.cypress.io/spec
|
|
181
|
+
// wrap the object so we can inspect it easily by clicking in the command log
|
|
182
|
+
cy.wrap(Cypress.spec).should('include.keys', ['name', 'relative', 'absolute'])
|
|
183
|
+
})
|
|
184
|
+
})
|
|
185
|
+
})
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
|
|
3
|
+
/// JSON fixture file can be loaded directly using
|
|
4
|
+
// the built-in JavaScript bundler
|
|
5
|
+
const requiredExample = require('../../fixtures/example')
|
|
6
|
+
|
|
7
|
+
context('Files', () => {
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
cy.visit('https://example.cypress.io/commands/files')
|
|
10
|
+
|
|
11
|
+
// load example.json fixture file and store
|
|
12
|
+
// in the test context object
|
|
13
|
+
cy.fixture('example.json').as('example')
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
it('cy.fixture() - load a fixture', () => {
|
|
17
|
+
// https://on.cypress.io/fixture
|
|
18
|
+
|
|
19
|
+
// Instead of writing a response inline you can
|
|
20
|
+
// use a fixture file's content.
|
|
21
|
+
|
|
22
|
+
// when application makes an Ajax request matching "GET **/comments/*"
|
|
23
|
+
// Cypress will intercept it and reply with the object in `example.json` fixture
|
|
24
|
+
cy.intercept('GET', '**/comments/*', { fixture: 'example.json' }).as('getComment')
|
|
25
|
+
|
|
26
|
+
// we have code that gets a comment when
|
|
27
|
+
// the button is clicked in scripts.js
|
|
28
|
+
cy.get('.fixture-btn').click()
|
|
29
|
+
|
|
30
|
+
cy.wait('@getComment').its('response.body')
|
|
31
|
+
.should('have.property', 'name')
|
|
32
|
+
.and('include', 'Using fixtures to represent data')
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('cy.fixture() or require - load a fixture', function () {
|
|
36
|
+
// we are inside the "function () { ... }"
|
|
37
|
+
// callback and can use test context object "this"
|
|
38
|
+
// "this.example" was loaded in "beforeEach" function callback
|
|
39
|
+
expect(this.example, 'fixture in the test context')
|
|
40
|
+
.to.deep.equal(requiredExample)
|
|
41
|
+
|
|
42
|
+
// or use "cy.wrap" and "should('deep.equal', ...)" assertion
|
|
43
|
+
cy.wrap(this.example)
|
|
44
|
+
.should('deep.equal', requiredExample)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('cy.readFile() - read file contents', () => {
|
|
48
|
+
// https://on.cypress.io/readfile
|
|
49
|
+
|
|
50
|
+
// You can read a file and yield its contents
|
|
51
|
+
// The filePath is relative to your project's root.
|
|
52
|
+
cy.readFile(Cypress.config('configFile')).then((config) => {
|
|
53
|
+
expect(config).to.be.an('string')
|
|
54
|
+
})
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('cy.writeFile() - write to a file', () => {
|
|
58
|
+
// https://on.cypress.io/writefile
|
|
59
|
+
|
|
60
|
+
// You can write to a file
|
|
61
|
+
|
|
62
|
+
// Use a response from a request to automatically
|
|
63
|
+
// generate a fixture file for use later
|
|
64
|
+
cy.request('https://jsonplaceholder.cypress.io/users')
|
|
65
|
+
.then((response) => {
|
|
66
|
+
cy.writeFile('cypress/fixtures/users.json', response.body)
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
cy.fixture('users').should((users) => {
|
|
70
|
+
expect(users[0].name).to.exist
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
// JavaScript arrays and objects are stringified
|
|
74
|
+
// and formatted into text.
|
|
75
|
+
cy.writeFile('cypress/fixtures/profile.json', {
|
|
76
|
+
id: 8739,
|
|
77
|
+
name: 'Jane',
|
|
78
|
+
email: 'jane@example.com',
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
cy.fixture('profile').should((profile) => {
|
|
82
|
+
expect(profile.name).to.eq('Jane')
|
|
83
|
+
})
|
|
84
|
+
})
|
|
85
|
+
})
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
|
|
3
|
+
context('Location', () => {
|
|
4
|
+
beforeEach(() => {
|
|
5
|
+
cy.visit('https://example.cypress.io/commands/location')
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
it('cy.hash() - get the current URL hash', () => {
|
|
9
|
+
// https://on.cypress.io/hash
|
|
10
|
+
cy.hash().should('be.empty')
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
it('cy.location() - get window.location', () => {
|
|
14
|
+
// https://on.cypress.io/location
|
|
15
|
+
cy.location().should((location) => {
|
|
16
|
+
expect(location.hash).to.be.empty
|
|
17
|
+
expect(location.href).to.eq('https://example.cypress.io/commands/location')
|
|
18
|
+
expect(location.host).to.eq('example.cypress.io')
|
|
19
|
+
expect(location.hostname).to.eq('example.cypress.io')
|
|
20
|
+
expect(location.origin).to.eq('https://example.cypress.io')
|
|
21
|
+
expect(location.pathname).to.eq('/commands/location')
|
|
22
|
+
expect(location.port).to.eq('')
|
|
23
|
+
expect(location.protocol).to.eq('https:')
|
|
24
|
+
expect(location.search).to.be.empty
|
|
25
|
+
})
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('cy.url() - get the current URL', () => {
|
|
29
|
+
// https://on.cypress.io/url
|
|
30
|
+
cy.url().should('eq', 'https://example.cypress.io/commands/location')
|
|
31
|
+
})
|
|
32
|
+
})
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
|
|
3
|
+
context('Misc', () => {
|
|
4
|
+
beforeEach(() => {
|
|
5
|
+
cy.visit('https://example.cypress.io/commands/misc')
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
it('cy.exec() - execute a system command', () => {
|
|
9
|
+
// execute a system command.
|
|
10
|
+
// so you can take actions necessary for
|
|
11
|
+
// your test outside the scope of Cypress.
|
|
12
|
+
// https://on.cypress.io/exec
|
|
13
|
+
|
|
14
|
+
// we can use Cypress.platform string to
|
|
15
|
+
// select appropriate command
|
|
16
|
+
// https://on.cypress/io/platform
|
|
17
|
+
cy.log(`Platform ${Cypress.platform} architecture ${Cypress.arch}`)
|
|
18
|
+
|
|
19
|
+
// on CircleCI Windows build machines we have a failure to run bash shell
|
|
20
|
+
// https://github.com/cypress-io/cypress/issues/5169
|
|
21
|
+
// so skip some of the tests by passing flag "--env circle=true"
|
|
22
|
+
const isCircleOnWindows = Cypress.platform === 'win32' && Cypress.env('circle')
|
|
23
|
+
|
|
24
|
+
if (isCircleOnWindows) {
|
|
25
|
+
cy.log('Skipping test on CircleCI')
|
|
26
|
+
|
|
27
|
+
return
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// cy.exec problem on Shippable CI
|
|
31
|
+
// https://github.com/cypress-io/cypress/issues/6718
|
|
32
|
+
const isShippable = Cypress.platform === 'linux' && Cypress.env('shippable')
|
|
33
|
+
|
|
34
|
+
if (isShippable) {
|
|
35
|
+
cy.log('Skipping test on ShippableCI')
|
|
36
|
+
|
|
37
|
+
return
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
cy.exec('echo Jane Lane')
|
|
41
|
+
.its('stdout').should('contain', 'Jane Lane')
|
|
42
|
+
|
|
43
|
+
if (Cypress.platform === 'win32') {
|
|
44
|
+
cy.exec(`print ${Cypress.config('configFile')}`)
|
|
45
|
+
.its('stderr').should('be.empty')
|
|
46
|
+
} else {
|
|
47
|
+
cy.exec(`cat ${Cypress.config('configFile')}`)
|
|
48
|
+
.its('stderr').should('be.empty')
|
|
49
|
+
|
|
50
|
+
cy.exec('pwd')
|
|
51
|
+
.its('code').should('eq', 0)
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it('cy.focused() - get the DOM element that has focus', () => {
|
|
56
|
+
// https://on.cypress.io/focused
|
|
57
|
+
cy.get('.misc-form').find('#name').click()
|
|
58
|
+
cy.focused().should('have.id', 'name')
|
|
59
|
+
|
|
60
|
+
cy.get('.misc-form').find('#description').click()
|
|
61
|
+
cy.focused().should('have.id', 'description')
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
context('Cypress.Screenshot', function () {
|
|
65
|
+
it('cy.screenshot() - take a screenshot', () => {
|
|
66
|
+
// https://on.cypress.io/screenshot
|
|
67
|
+
cy.screenshot('my-image')
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
it('Cypress.Screenshot.defaults() - change default config of screenshots', function () {
|
|
71
|
+
Cypress.Screenshot.defaults({
|
|
72
|
+
blackout: ['.foo'],
|
|
73
|
+
capture: 'viewport',
|
|
74
|
+
clip: { x: 0, y: 0, width: 200, height: 200 },
|
|
75
|
+
scale: false,
|
|
76
|
+
disableTimersAndAnimations: true,
|
|
77
|
+
screenshotOnRunFailure: true,
|
|
78
|
+
onBeforeScreenshot () { },
|
|
79
|
+
onAfterScreenshot () { },
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
it('cy.wrap() - wrap an object', () => {
|
|
85
|
+
// https://on.cypress.io/wrap
|
|
86
|
+
cy.wrap({ foo: 'bar' })
|
|
87
|
+
.should('have.property', 'foo')
|
|
88
|
+
.and('include', 'bar')
|
|
89
|
+
})
|
|
90
|
+
})
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
|
|
3
|
+
context('Navigation', () => {
|
|
4
|
+
beforeEach(() => {
|
|
5
|
+
cy.visit('https://example.cypress.io')
|
|
6
|
+
cy.get('.navbar-nav').contains('Commands').click()
|
|
7
|
+
cy.get('.dropdown-menu').contains('Navigation').click()
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
it('cy.go() - go back or forward in the browser\'s history', () => {
|
|
11
|
+
// https://on.cypress.io/go
|
|
12
|
+
|
|
13
|
+
cy.location('pathname').should('include', 'navigation')
|
|
14
|
+
|
|
15
|
+
cy.go('back')
|
|
16
|
+
cy.location('pathname').should('not.include', 'navigation')
|
|
17
|
+
|
|
18
|
+
cy.go('forward')
|
|
19
|
+
cy.location('pathname').should('include', 'navigation')
|
|
20
|
+
|
|
21
|
+
// clicking back
|
|
22
|
+
cy.go(-1)
|
|
23
|
+
cy.location('pathname').should('not.include', 'navigation')
|
|
24
|
+
|
|
25
|
+
// clicking forward
|
|
26
|
+
cy.go(1)
|
|
27
|
+
cy.location('pathname').should('include', 'navigation')
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it('cy.reload() - reload the page', () => {
|
|
31
|
+
// https://on.cypress.io/reload
|
|
32
|
+
cy.reload()
|
|
33
|
+
|
|
34
|
+
// reload the page without using the cache
|
|
35
|
+
cy.reload(true)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it('cy.visit() - visit a remote url', () => {
|
|
39
|
+
// https://on.cypress.io/visit
|
|
40
|
+
|
|
41
|
+
// Visit any sub-domain of your current domain
|
|
42
|
+
// Pass options to the visit
|
|
43
|
+
cy.visit('https://example.cypress.io/commands/navigation', {
|
|
44
|
+
timeout: 50000, // increase total time for the visit to resolve
|
|
45
|
+
onBeforeLoad (contentWindow) {
|
|
46
|
+
// contentWindow is the remote page's window object
|
|
47
|
+
expect(typeof contentWindow === 'object').to.be.true
|
|
48
|
+
},
|
|
49
|
+
onLoad (contentWindow) {
|
|
50
|
+
// contentWindow is the remote page's window object
|
|
51
|
+
expect(typeof contentWindow === 'object').to.be.true
|
|
52
|
+
},
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
|
+
})
|