Skip to content

Commit 56ada0e

Browse files
committed
Mock new API for tests, install pre-release Cy12 binary
1 parent 3b2e725 commit 56ada0e

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

cypress.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const {defineConfig} = require('cypress')
22

33
module.exports = defineConfig({
4+
e2e: {},
45
video: false,
56
})

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"@testing-library/dom": "^8.1.0"
4545
},
4646
"devDependencies": {
47-
"cypress": "^10.0.0",
47+
"cypress": "https://cdn.cypress.io/beta/npm/12.0.0/linux-x64/release/12.0.0-cc63b13085591b70826c909119784e7d358ea56e/cypress.tgz",
4848
"kcd-scripts": "^11.2.0",
4949
"npm-run-all": "^4.1.5",
5050
"typescript": "^4.3.5"

src/__tests__/add-commands.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@ import {commands} from '../'
22

33
test('adds commands to Cypress', () => {
44
const addMock = jest.fn().mockName('Cypress.Commands.add')
5-
global.Cypress = {Commands: {add: addMock}}
5+
const addQueryMock = jest.fn().mockName('Cypress.Commands.addQuery')
6+
global.Cypress = {Commands: {add: addMock, addQuery: addQueryMock}}
67
global.cy = {}
78

89
require('../add-commands')
910

10-
expect(addMock).toHaveBeenCalledTimes(commands.length + 1) // we're also adding a configuration command
11+
expect(addQueryMock).toHaveBeenCalledTimes(commands.length)
12+
expect(addMock).toHaveBeenCalledTimes(1) // we're also adding a configuration command
1113
commands.forEach(({name}, index) => {
12-
expect(addMock.mock.calls[index]).toMatchObject([
14+
expect(addQueryMock.mock.calls[index]).toMatchObject([
1315
name,
14-
{},
1516
// We get a new function that is `command.bind(null, cy)` i.e. global `cy` passed into the first argument.
1617
// The commands themselves will be tested separately in the Cypress end-to-end tests.
1718
expect.any(Function),

src/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ function getFirstElement(jqueryOrElement) {
77

88
export {getFirstElement}
99

10-
/* globals Cypress, cy */
10+
/* globals Cypress */

0 commit comments

Comments
 (0)