Skip to content

Commit a4c6703

Browse files
committed
fix(style): prettier
1 parent 3164a7c commit a4c6703

File tree

129 files changed

+6858
-7384
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+6858
-7384
lines changed

bin/codecept.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const commandFlags = {
3232
}
3333

3434
const errorHandler =
35-
(fn) =>
35+
fn =>
3636
async (...args) => {
3737
try {
3838
await fn(...args)
@@ -286,7 +286,7 @@ program
286286

287287
.action(require('../lib/command/run-rerun'))
288288

289-
program.on('command:*', (cmd) => {
289+
program.on('command:*', cmd => {
290290
console.log(`\nUnknown command ${cmd}\n`)
291291
program.outputHelp()
292292
})

lib/assert/empty.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const output = require('../output')
55

66
class EmptinessAssertion extends Assertion {
77
constructor(params) {
8-
super((value) => {
8+
super(value => {
99
if (Array.isArray(value)) {
1010
return value.length === 0
1111
}
@@ -22,9 +22,7 @@ class EmptinessAssertion extends Assertion {
2222
const err = new AssertionFailedError(this.params, "{{customMessage}}expected {{subject}} '{{value}}' {{type}}")
2323

2424
err.cliMessage = () => {
25-
const msg = err.template
26-
.replace('{{value}}', output.colors.bold('{{value}}'))
27-
.replace('{{subject}}', output.colors.bold('{{subject}}'))
25+
const msg = err.template.replace('{{value}}', output.colors.bold('{{value}}')).replace('{{subject}}', output.colors.bold('{{subject}}'))
2826
return template(msg, this.params)
2927
}
3028
return err
@@ -39,5 +37,5 @@ class EmptinessAssertion extends Assertion {
3937

4038
module.exports = {
4139
Assertion: EmptinessAssertion,
42-
empty: (subject) => new EmptinessAssertion({ subject }),
40+
empty: subject => new EmptinessAssertion({ subject }),
4341
}

lib/assert/equal.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ class EqualityAssertion extends Assertion {
1818
getException() {
1919
const params = this.params
2020
params.jar = template(params.jar, params)
21-
const err = new AssertionFailedError(
22-
params,
23-
'{{customMessage}}expected {{jar}} "{{expected}}" {{type}} "{{actual}}"',
24-
)
21+
const err = new AssertionFailedError(params, '{{customMessage}}expected {{jar}} "{{expected}}" {{type}} "{{actual}}"')
2522
err.showDiff = false
2623
if (typeof err.cliMessage === 'function') {
2724
err.message = err.cliMessage()
@@ -42,8 +39,8 @@ class EqualityAssertion extends Assertion {
4239

4340
module.exports = {
4441
Assertion: EqualityAssertion,
45-
equals: (jar) => new EqualityAssertion({ jar }),
46-
urlEquals: (baseUrl) => {
42+
equals: jar => new EqualityAssertion({ jar }),
43+
urlEquals: baseUrl => {
4744
const assert = new EqualityAssertion({ jar: 'url of current page' })
4845
assert.comparator = function (expected, actual) {
4946
if (expected.indexOf('http') !== 0) {
@@ -53,5 +50,5 @@ module.exports = {
5350
}
5451
return assert
5552
},
56-
fileEquals: (file) => new EqualityAssertion({ file, jar: 'contents of {{file}}' }),
53+
fileEquals: file => new EqualityAssertion({ file, jar: 'contents of {{file}}' }),
5754
}

lib/assert/include.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class InclusionAssertion extends Assertion {
1010
params.jar = params.jar || 'string'
1111
const comparator = function (needle, haystack) {
1212
if (Array.isArray(haystack)) {
13-
return haystack.filter((part) => part.indexOf(needle) >= 0).length > 0
13+
return haystack.filter(part => part.indexOf(needle) >= 0).length > 0
1414
}
1515
return haystack.indexOf(needle) >= 0
1616
}
@@ -28,9 +28,7 @@ class InclusionAssertion extends Assertion {
2828
this.params.haystack = this.params.haystack.join('\n___(next element)___\n')
2929
}
3030
err.cliMessage = function () {
31-
const msg = this.template
32-
.replace('{{jar}}', output.colors.bold('{{jar}}'))
33-
.replace('{{needle}}', output.colors.bold('{{needle}}'))
31+
const msg = this.template.replace('{{jar}}', output.colors.bold('{{jar}}')).replace('{{needle}}', output.colors.bold('{{needle}}'))
3432
return template(msg, this.params)
3533
}
3634
return err
@@ -66,11 +64,11 @@ class InclusionAssertion extends Assertion {
6664

6765
module.exports = {
6866
Assertion: InclusionAssertion,
69-
includes: (needleType) => {
67+
includes: needleType => {
7068
needleType = needleType || 'string'
7169
return new InclusionAssertion({ jar: needleType })
7270
},
73-
fileIncludes: (file) => new InclusionAssertion({ file, jar: 'file {{file}}' }),
71+
fileIncludes: file => new InclusionAssertion({ file, jar: 'file {{file}}' }),
7472
}
7573

7674
function escapeRegExp(str) {

lib/assert/throws.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ function errorThrown(actual, expected) {
1111
throw new Error(`Expected error to be thrown with message ${expected} while '${msg}' caught`)
1212
}
1313
if (typeof expected === 'object') {
14-
if (actual.constructor.name !== expected.constructor.name)
15-
throw new Error(`Expected ${expected} error to be thrown but ${actual} was caught`)
16-
if (expected.message && expected.message !== msg)
17-
throw new Error(`Expected error to be thrown with message ${expected.message} while '${msg}' caught`)
14+
if (actual.constructor.name !== expected.constructor.name) throw new Error(`Expected ${expected} error to be thrown but ${actual} was caught`)
15+
if (expected.message && expected.message !== msg) throw new Error(`Expected error to be thrown with message ${expected.message} while '${msg}' caught`)
1816
}
1917
return null
2018
}

lib/assert/truth.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ const output = require('../output')
55

66
class TruthAssertion extends Assertion {
77
constructor(params) {
8-
super((value) => {
8+
super(value => {
99
if (Array.isArray(value)) {
10-
return value.filter((val) => !!val).length > 0
10+
return value.filter(val => !!val).length > 0
1111
}
1212
return !!value
1313
}, params)

lib/command/configMigrate.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ module.exports = function (initPath) {
1414

1515
print()
1616
print(` Welcome to ${colors.magenta.bold('CodeceptJS')} configuration migration tool`)
17-
print(
18-
` It will help you switch from ${colors.cyan.bold('.json')} to ${colors.magenta.bold('.js')} config format at ease`,
19-
)
17+
print(` It will help you switch from ${colors.cyan.bold('.json')} to ${colors.magenta.bold('.js')} config format at ease`)
2018
print()
2119

2220
if (!path) {
@@ -53,7 +51,7 @@ module.exports = function (initPath) {
5351
default: true,
5452
},
5553
])
56-
.then((result) => {
54+
.then(result => {
5755
if (result.configFile) {
5856
const jsonConfigFile = path.join(testsPath, 'codecept.js')
5957
const config = JSON.parse(fs.readFileSync(jsonConfigFile, 'utf8'))

lib/command/definitions.js

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,7 @@ const actingHelpers = [...require('../plugin/standardActingHelpers'), 'REST']
2121
*
2222
* @returns {string}
2323
*/
24-
const getDefinitionsFileContent = ({
25-
hasCustomHelper,
26-
hasCustomStepsFile,
27-
helperNames,
28-
supportObject,
29-
importPaths,
30-
translations,
31-
}) => {
24+
const getDefinitionsFileContent = ({ hasCustomHelper, hasCustomStepsFile, helperNames, supportObject, importPaths, translations }) => {
3225
const getHelperListFragment = ({ hasCustomHelper, hasCustomStepsFile }) => {
3326
if (hasCustomHelper && hasCustomStepsFile) {
3427
return `${['ReturnType<steps_file>', 'WithTranslation<Methods>'].join(', ')}`
@@ -73,13 +66,7 @@ const getDefinitionsFileContent = ({
7366
*
7467
* @returns {string}
7568
*/
76-
const generateDefinitionsContent = ({
77-
importPathsFragment,
78-
supportObjectsTypeFragment,
79-
methodsTypeFragment,
80-
helpersListFragment,
81-
translatedActionsFragment,
82-
}) => {
69+
const generateDefinitionsContent = ({ importPathsFragment, supportObjectsTypeFragment, methodsTypeFragment, helpersListFragment, translatedActionsFragment }) => {
8370
return `/// <reference types='codeceptjs' />
8471
${importPathsFragment}
8572
@@ -185,15 +172,12 @@ module.exports = function (genPath, options) {
185172
namespaceTranslationAliases.push(`interface ${translations.vocabulary.I} extends WithTranslation<Methods> {}`)
186173

187174
namespaceTranslationAliases.push(' namespace Translation {')
188-
definitionsFileContent = definitionsFileContent.replace(
189-
'namespace Translation {',
190-
namespaceTranslationAliases.join('\n'),
191-
)
175+
definitionsFileContent = definitionsFileContent.replace('namespace Translation {', namespaceTranslationAliases.join('\n'))
192176

193177
const translationAliases = []
194178

195179
if (translations.vocabulary.contexts) {
196-
Object.keys(translations.vocabulary.contexts).forEach((k) => {
180+
Object.keys(translations.vocabulary.contexts).forEach(k => {
197181
translationAliases.push(`declare const ${translations.vocabulary.contexts[k]}: typeof ${k};`)
198182
})
199183
}
@@ -222,11 +206,7 @@ function getPath(originalPath, targetFolderPath, testsPath) {
222206
if (!parsedPath.dir.startsWith('.')) return path.posix.join(parsedPath.dir, parsedPath.base)
223207
const relativePath = path.posix.relative(
224208
targetFolderPath.split(path.sep).join(path.posix.sep),
225-
path.posix.join(
226-
testsPath.split(path.sep).join(path.posix.sep),
227-
parsedPath.dir.split(path.sep).join(path.posix.sep),
228-
parsedPath.base.split(path.sep).join(path.posix.sep),
229-
),
209+
path.posix.join(testsPath.split(path.sep).join(path.posix.sep), parsedPath.dir.split(path.sep).join(path.posix.sep), parsedPath.base.split(path.sep).join(path.posix.sep)),
230210
)
231211

232212
return relativePath.startsWith('.') ? relativePath : `./${relativePath}`

lib/command/generate.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module.exports.test = function (genPath) {
3535
type: 'input',
3636
name: 'feature',
3737
message: 'Feature which is being tested (ex: account, login, etc)',
38-
validate: (val) => !!val,
38+
validate: val => !!val,
3939
},
4040
{
4141
type: 'input',
@@ -46,7 +46,7 @@ module.exports.test = function (genPath) {
4646
},
4747
},
4848
])
49-
.then((result) => {
49+
.then(result => {
5050
const testFilePath = path.dirname(path.join(testsPath, config.tests)).replace(/\*\*$/, '')
5151
let testFile = path.join(testFilePath, result.filename)
5252
const ext = path.extname(testFile)
@@ -63,9 +63,7 @@ module.exports.test = function (genPath) {
6363
testContent = testContent.replace('{{actor}}', container.translation().I)
6464
if (vocabulary.contexts.Feature) testContent = testContent.replace('Feature', vocabulary.contexts.Feature)
6565
if (vocabulary.contexts.Scenario) testContent = testContent.replace('Scenario', vocabulary.contexts.Scenario)
66-
output.print(
67-
`Test was created in ${colors.bold(config.translation)} localization. See: https://codecept.io/translation/`,
68-
)
66+
output.print(`Test was created in ${colors.bold(config.translation)} localization. See: https://codecept.io/translation/`)
6967
} else {
7068
testContent = testContent.replace('{{actor}}', 'I')
7169
}
@@ -128,13 +126,13 @@ module.exports.pageObject = function (genPath, opts) {
128126
type: 'input',
129127
name: 'name',
130128
message: `Name of a ${kind} object`,
131-
validate: (val) => !!val,
129+
validate: val => !!val,
132130
},
133131
{
134132
type: 'input',
135133
name: 'filename',
136134
message: 'Where should it be stored',
137-
default: (answers) => `./${kind}s/${answers.name}.${extension}`,
135+
default: answers => `./${kind}s/${answers.name}.${extension}`,
138136
},
139137
{
140138
type: 'list',
@@ -144,7 +142,7 @@ module.exports.pageObject = function (genPath, opts) {
144142
default: 'module',
145143
},
146144
])
147-
.then((result) => {
145+
.then(result => {
148146
const pageObjectFile = path.join(testsPath, result.filename)
149147
const dir = path.dirname(pageObjectFile)
150148
if (!fileExists(dir)) fs.mkdirSync(dir)
@@ -194,9 +192,7 @@ module.exports.pageObject = function (genPath, opts) {
194192
try {
195193
generateDefinitions(testsPath, {})
196194
} catch (_err) {
197-
output.print(
198-
`Run ${colors.green('npx codeceptjs def')} to update your types to get auto-completion for object.`,
199-
)
195+
output.print(`Run ${colors.green('npx codeceptjs def')} to update your types to get auto-completion for object.`)
200196
}
201197
})
202198
}
@@ -241,16 +237,16 @@ module.exports.helper = function (genPath) {
241237
type: 'input',
242238
name: 'name',
243239
message: 'Name of a Helper',
244-
validate: (val) => !!val,
240+
validate: val => !!val,
245241
},
246242
{
247243
type: 'input',
248244
name: 'filename',
249245
message: 'Where should it be stored',
250-
default: (answers) => `./${answers.name.toLowerCase()}_helper.${extension}`,
246+
default: answers => `./${answers.name.toLowerCase()}_helper.${extension}`,
251247
},
252248
])
253-
.then((result) => {
249+
.then(result => {
254250
const name = ucfirst(result.name)
255251
const helperFile = path.join(testsPath, result.filename)
256252
const dir = path.dirname(helperFile)

lib/command/info.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ module.exports = async function (path) {
3434
output.print('***************************************')
3535
output.print('If you have questions ask them in our Slack: http://bit.ly/chat-codeceptjs')
3636
output.print('Or ask them on our discussion board: https://codecept.discourse.group/')
37-
output.print(
38-
'Please copy environment info when you report issues on GitHub: https://github.com/Codeception/CodeceptJS/issues',
39-
)
37+
output.print('Please copy environment info when you report issues on GitHub: https://github.com/Codeception/CodeceptJS/issues')
4038
output.print('***************************************')
4139
}
4240

0 commit comments

Comments
 (0)