Skip to content

Commit 792ce21

Browse files
author
DavertMik
committed
fixed more tests
1 parent c7561d2 commit 792ce21

File tree

11 files changed

+110
-117
lines changed

11 files changed

+110
-117
lines changed

lib/command/check.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { getConfig, getTestRoot } from './utils.js'
22
import Codecept from '../codecept.js'
33
import output from '../output.js'
44
import store from '../store.js'
5-
import container from '../container.js'
5+
import Container from '../container.js'
66
import figures from 'figures'
77
import chalk from 'chalk'
88
import { createTest } from '../mocha/test.js'
@@ -45,14 +45,14 @@ export default async function (options) {
4545
let codecept
4646
try {
4747
codecept = new Codecept(config, options)
48-
codecept.init(testRoot)
49-
await container.started()
48+
await codecept.init(testRoot)
49+
await Container.started()
5050
checks.container = true
5151
} catch (err) {
5252
checks.container = err
5353
}
5454

55-
const standardActingHelpers = container.STANDARD_ACTING_HELPERS
55+
const standardActingHelpers = Container.STANDARD_ACTING_HELPERS
5656

5757
printCheck('container', checks['container'])
5858

@@ -70,7 +70,7 @@ export default async function (options) {
7070
if (codecept) {
7171
try {
7272
codecept.loadTests()
73-
const mocha = container.mocha()
73+
const mocha = Container.mocha()
7474
mocha.files = codecept.testFiles
7575
mocha.loadFiles()
7676
mocha.suite.suites.forEach(suite => {
@@ -97,7 +97,7 @@ export default async function (options) {
9797

9898
store.dryRun = true
9999

100-
const helpers = container.helpers()
100+
const helpers = Container.helpers()
101101

102102
try {
103103
if (!Object.keys(helpers).length) throw new Error('No helpers found')
@@ -112,7 +112,7 @@ export default async function (options) {
112112

113113
printCheck('helpers', checks['helpers'], `${Object.keys(helpers).join(', ')}`)
114114

115-
const pageObjects = container.support()
115+
const pageObjects = Container.support()
116116

117117
try {
118118
if (Object.keys(pageObjects).length) {
@@ -127,10 +127,10 @@ export default async function (options) {
127127
printCheck('page objects', checks['pageObjects'], `Total: ${Object.keys(pageObjects).length} support objects`)
128128

129129
checks.plugins = true // how to check plugins?
130-
printCheck('plugins', checks['plugins'], Object.keys(container.plugins()).join(', '))
130+
printCheck('plugins', checks['plugins'], Object.keys(Container.plugins()).join(', '))
131131

132132
if (Object.keys(helpers).length) {
133-
const suite = container.mocha().suite
133+
const suite = Container.mocha().suite
134134
const test = createTest('test', () => {})
135135
checks.setup = true
136136
for (const helper of Object.values(helpers)) {
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
function ConnectionRefused(err) {
2-
this.message = "Can't connect to WebDriver.\n";
3-
this.message += `${err}\n\n`;
4-
this.message += 'Please make sure Selenium Server is running and accessible';
5-
this.stack = err.stack;
2+
this.message = "Can't connect to WebDriver.\n"
3+
this.message += `${err}\n\n`
4+
this.message += 'Please make sure Selenium Server is running and accessible'
5+
this.stack = err.stack
66
}
77

8-
ConnectionRefused.prototype = Object.create(Error.prototype);
8+
ConnectionRefused.prototype = Object.create(Error.prototype)
99

10-
module.exports = ConnectionRefused;
10+
export default ConnectionRefused

lib/helper/errors/ElementAssertion.js

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,33 @@
1-
const Locator = require('../../locator');
1+
import Locator from '../../locator.js'
22

3-
const prefixMessage = 'Element';
3+
const prefixMessage = 'Element'
44

55
function seeElementError(locator) {
66
if (typeof locator === 'object') {
7-
locator = JSON.stringify(locator);
7+
locator = JSON.stringify(locator)
88
}
9-
throw new Error(`${prefixMessage} "${(new Locator(locator))}" is still visible on page.`);
9+
throw new Error(`${prefixMessage} "${new Locator(locator)}" is still visible on page.`)
1010
}
1111

1212
function seeElementInDOMError(locator) {
1313
if (typeof locator === 'object') {
14-
locator = JSON.stringify(locator);
14+
locator = JSON.stringify(locator)
1515
}
16-
throw new Error(`${prefixMessage} "${(new Locator(locator))}" is still seen in DOM.`);
16+
throw new Error(`${prefixMessage} "${new Locator(locator)}" is still seen in DOM.`)
1717
}
1818

1919
function dontSeeElementError(locator) {
2020
if (typeof locator === 'object') {
21-
locator = JSON.stringify(locator);
21+
locator = JSON.stringify(locator)
2222
}
23-
throw new Error(`${prefixMessage} "${(new Locator(locator))}" is not visible on page.`);
23+
throw new Error(`${prefixMessage} "${new Locator(locator)}" is not visible on page.`)
2424
}
2525

2626
function dontSeeElementInDOMError(locator) {
2727
if (typeof locator === 'object') {
28-
locator = JSON.stringify(locator);
28+
locator = JSON.stringify(locator)
2929
}
30-
throw new Error(`${prefixMessage} "${(new Locator(locator))}" is not seen in DOM.`);
30+
throw new Error(`${prefixMessage} "${new Locator(locator)}" is not seen in DOM.`)
3131
}
3232

33-
module.exports = {
34-
seeElementError,
35-
dontSeeElementError,
36-
seeElementInDOMError,
37-
dontSeeElementInDOMError,
38-
};
33+
export { seeElementError, dontSeeElementError, seeElementInDOMError, dontSeeElementInDOMError }
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
function RemoteBrowserConnectionRefused(err) {
2-
this.message = 'Cannot connect to websocket endpoint.\n\n';
3-
this.message += 'Please make sure remote browser is running and accessible.';
4-
this.stack = err.error || err;
2+
this.message = 'Cannot connect to websocket endpoint.\n\n'
3+
this.message += 'Please make sure remote browser is running and accessible.'
4+
this.stack = err.error || err
55
}
66

7-
RemoteBrowserConnectionRefused.prototype = Object.create(Error.prototype);
7+
RemoteBrowserConnectionRefused.prototype = Object.create(Error.prototype)
88

9-
module.exports = RemoteBrowserConnectionRefused;
9+
export default RemoteBrowserConnectionRefused

lib/helper/extras/Console.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,31 @@
33
*/
44
class Console {
55
constructor() {
6-
this._logEntries = [];
6+
this._logEntries = []
77
}
88

99
get entries() {
10-
return this._logEntries;
10+
return this._logEntries
1111
}
1212

1313
clear() {
14-
this._logEntries = [];
14+
this._logEntries = []
1515
}
1616

1717
includes(msg) {
18-
const prev = this._logEntries[this._logEntries.length - 1];
19-
if (!prev) return false;
20-
const text = msg.text && msg.text() || msg._text || '';
21-
const prevText = prev.text && prev.text() || prev._text || '';
22-
return text === prevText;
18+
const prev = this._logEntries[this._logEntries.length - 1]
19+
if (!prev) return false
20+
const text = (msg.text && msg.text()) || msg._text || ''
21+
const prevText = (prev.text && prev.text()) || prev._text || ''
22+
return text === prevText
2323
}
2424

2525
add(entry) {
2626
if (Array.isArray(entry)) {
27-
this._logEntries = this._logEntries.concat(entry);
27+
this._logEntries = this._logEntries.concat(entry)
2828
}
29-
this._logEntries.push(entry);
29+
this._logEntries.push(entry)
3030
}
3131
}
3232

33-
module.exports = Console;
33+
export default Console
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
1-
module.exports.createValueEngine = () => {
1+
export const createValueEngine = () => {
22
return {
33
// Creates a selector that matches given target when queried at the root.
44
// Can return undefined if unable to create one.
55

66
create(root, target) {
7-
return null;
7+
return null
88
},
99

1010
// Returns the first element matching given selector in the root's subtree.
1111
query(root, selector) {
1212
if (!root) {
13-
return null;
13+
return null
1414
}
15-
return `${root.value}`.includes(selector) ? root : null;
15+
return `${root.value}`.includes(selector) ? root : null
1616
},
1717

1818
// Returns all elements matching given selector in the root's subtree.
1919
queryAll(root, selector) {
2020
if (!root) {
21-
return null;
21+
return null
2222
}
23-
return `${root.value}`.includes(selector) ? root : null;
23+
return `${root.value}`.includes(selector) ? root : null
2424
},
25-
};
26-
};
25+
}
26+
}
2727

28-
module.exports.createDisabledEngine = () => {
28+
export const createDisabledEngine = () => {
2929
return {
3030
// Creates a selector that matches given target when queried at the root.
3131
// Can return undefined if unable to create one.
3232

3333
create(root, target) {
34-
return null;
34+
return null
3535
},
3636

3737
// Returns the first element matching given selector in the root's subtree.
3838
query(root, value) {
39-
const bool = value === 'true';
39+
const bool = value === 'true'
4040
if (!root) {
41-
return null;
41+
return null
4242
}
43-
return root.disabled === bool ? root : null;
43+
return root.disabled === bool ? root : null
4444
},
4545

4646
// Returns all elements matching given selector in the root's subtree.
4747
queryAll(root, value) {
48-
const bool = value === 'true';
48+
const bool = value === 'true'
4949
if (!root) {
50-
return null;
50+
return null
5151
}
52-
return root.disabled === bool ? root : null;
52+
return root.disabled === bool ? root : null
5353
},
54-
};
55-
};
54+
}
55+
}
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
async function findReact(matcher, locator) {
2-
let _locator = `_react=${locator.react}`;
3-
let props = '';
2+
let _locator = `_react=${locator.react}`
3+
let props = ''
44

55
if (locator.props) {
6-
props += propBuilder(locator.props);
7-
_locator += props;
6+
props += propBuilder(locator.props)
7+
_locator += props
88
}
9-
return matcher.locator(_locator).all();
9+
return matcher.locator(_locator).all()
1010
}
1111

1212
async function findVue(matcher, locator) {
13-
let _locator = `_vue=${locator.vue}`;
14-
let props = '';
13+
let _locator = `_vue=${locator.vue}`
14+
let props = ''
1515

1616
if (locator.props) {
17-
props += propBuilder(locator.props);
18-
_locator += props;
17+
props += propBuilder(locator.props)
18+
_locator += props
1919
}
20-
return matcher.locator(_locator).all();
20+
return matcher.locator(_locator).all()
2121
}
2222

2323
async function findByPlaywrightLocator(matcher, locator) {
24-
if (locator && locator.toString().includes(process.env.testIdAttribute)) return matcher.getByTestId(locator.pw.value.split('=')[1]);
25-
return matcher.locator(locator.pw).all();
24+
if (locator && locator.toString().includes(process.env.testIdAttribute)) return matcher.getByTestId(locator.pw.value.split('=')[1])
25+
return matcher.locator(locator.pw).all()
2626
}
2727

2828
function propBuilder(props) {
29-
let _props = '';
29+
let _props = ''
3030

3131
for (const [key, value] of Object.entries(props)) {
3232
if (typeof value === 'object') {
3333
for (const [k, v] of Object.entries(value)) {
34-
_props += `[${key}.${k} = "${v}"]`;
34+
_props += `[${key}.${k} = "${v}"]`
3535
}
3636
} else {
37-
_props += `[${key} = "${value}"]`;
37+
_props += `[${key} = "${value}"]`
3838
}
3939
}
40-
return _props;
40+
return _props
4141
}
4242

43-
module.exports = { findReact, findVue, findByPlaywrightLocator };
43+
export { findReact, findVue, findByPlaywrightLocator }

lib/helper/extras/Popup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,4 @@ class Popup {
6464
}
6565
}
6666

67-
module.exports = Popup
67+
export default Popup

0 commit comments

Comments
 (0)