Skip to content

Commit 015bf04

Browse files
committed
fix: refactor to use import and export internally
1 parent 9cf0334 commit 015bf04

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
node_modules/
2+
cypress/videos

src/get-by.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export const getByCommand = (name) => (label) => {
2+
cy.log(`**${name}**`)
3+
cy.contains('label', label)
4+
.invoke('attr', 'for')
5+
.then((id) => {
6+
cy.get('#' + id)
7+
})
8+
}

src/index.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1+
import { getByCommand } from './get-by'
12
export const registerCommand = (name = 'getByLabel') => {
2-
const getByCommand = (label) => {
3-
cy.log(`**${name}**`)
4-
cy.contains('label', label)
5-
.invoke('attr', 'for')
6-
.then((id) => {
7-
cy.get('#' + id)
8-
})
9-
}
10-
11-
Cypress.Commands.add(name, getByCommand)
3+
const getByName = getByCommand(name)
4+
Cypress.Commands.add(name, getByName)
125
}

0 commit comments

Comments
 (0)