Classes
Members
-
<static> cwd
-
<static, constant> hostname
-
- Source:
Properties:
Name Type Description hostname
string Host name of machine where
glacejs
framework is launched. Despite of machine hostname can be changed during script execution the probability that hostname will be changed during tests execution is low. That's why it's kept as property and in low case, because hostname is case insensitive.
Methods
-
<static> capitalize(string)
-
Capitalizes the first letter of a string. It doesn't influence to case of other letters.
Parameters:
Name Type Description string
string String to capitalize.
- Source:
Returns:
Capitalized string.
- Type
- string
Example
U.capitalize('hello'); // 'Hello' U.capitalize('Hello'); // 'Hello' U.capitalize('hEllo'); // 'HEllo'
-
<static> coalesce(values)
-
Pick default value for variable among listed values.
Parameters:
Name Type Argument Description values
* <repeatable>
Sequence of variable values.
- Source:
Returns:
First defined value or
null
if no one is defined.- Type
- *
Example
U.coalesce(); // null U.coalesce(undefined); // null U.coalesce(undefined, 1); // 1 U.coalesce(undefined, 1, 2); // 1 U.coalesce(null, 1); // null
-
<async, static> debug( [helpMessage])
-
Interactive debugger with syntax highlighting and autocomplete.
Parameters:
Name Type Argument Description helpMessage
string <optional>
Help message.
Returns:
- Type
- Promise
-
<static> docString()
-
Activates docstring support for js functions.
-
<static> each2each(l [, p])
-
Creates each to each combinations of sets.
Parameters:
Name Type Argument Description l
Array.<Array> Array of arrays to combine.
p
function <optional>
<nullable>
Function to process element before adding to combination. It passes two arguments:
e
- a new element to add;c
- assembling combination; By default it just pushese
toc
.- Source:
Returns:
List of combinations.
- Type
- Array.<Array>
Example
each2each([[1, 2], [3, 4]]); // [[1, 3], [1, 4], [2, 3], [2, 4]] each2each([[1, 2], [3, 4]], e => e + 1); // [[2, 4], [2, 5], [3, 4], [3, 5]] each2each([[1, 2], [3, 4]], (e, c) => e + _.sum(c)); // [[1, 4], [1, 5], [2, 5], [2, 6]]
-
<static> exit(source)
-
Exits process with error printing.
Parameters:
Name Type Description source
string Source of fatal error.
Returns:
Function with takes error to print and exits process.
- Type
- function
-
<static> filesByDate(dir [, opts])
-
Sorts files by date in folder.
Parameters:
Name Type Argument Description dir
string Path to directory.
opts
object <optional>
Options.
Properties
Name Type Argument Default Description desc
boolean <optional>
false Flag to reverse order.
Returns:
Sequence of files sorted by date
- Type
- Array.<string>
-
<static> filesByOrder(dir [, opts])
-
Files sorted by order.
Parameters:
Name Type Argument Description dir
string Path to directory.
opts
object <optional>
Options.
Properties
Name Type Argument Default Description desc
boolean <optional>
false Flag to reverse order.
Returns:
Sequence of files sorted by order.
- Type
- Array.<string>
-
<static> getReqKey(req)
-
Helper to generate request key for storage.
Parameters:
Name Type Description req
Request Client request.
Returns:
Request key according to its method, host, url.
- Type
- string
-
<static> help( [d])
-
Help
Parameters:
Name Type Argument Description d
function <optional>
Function to manage describe message: join, colorize, etc.
Returns:
Preconfigured yargs.
- Type
- yargs
-
<static> isInScreen(obj, screen [, opts])
-
Defines whether object is located on screen or no.
Parameters:
Name Type Argument Description obj
object Object which may be on screen.
screen
object Screen object.
opts
object <optional>
Options.
Properties
Name Type Argument Default Description fully
boolean <optional>
false Flag to check full presence on screen.
Returns:
true
if it is on screen,false
otherwise.- Type
- boolean
-
<async, static> killProcs(procName)
-
Helper to kill processes by name.
Parameters:
Name Type Description procName
string Process name or chunk of name.
Returns:
- Type
- Promise.<void>
-
<static> makeFixture( [opts])
-
Glace
fixtures factory.Provides easy way to make a fixture with hooks related with shared context.
Parameters:
Name Type Argument Description opts
object <optional>
Options.
Properties
Name Type Argument Description before
function <optional>
Callback of
before
hook.after
function <optional>
Callback of
after
hook.beforeChunk
function <optional>
Callback of
beforeChunk
hook.afterChunk
function <optional>
Callback of
afterChunk
hook.Returns:
- Fixture.
- Type
- function
-
<static> missedWords(text, words [, firstMissedOnly])
-
Detects words if they are missed in text (case-sensitive).
Parameters:
Name Type Argument Default Description text
string Text where words are looked for.
words
Array.<string> Filtered words.
firstMissedOnly
boolean <optional>
false Flag to return first missed word only. It reduces searching time and recommended to use if not need to get all missed words.
- Source:
Returns:
- Array of missed words.
- Type
- Array.<string>
Example
U.missedWords("hello world", ["hello", "man"]); // ["man"]
-
<static> mkpath(paths)
-
Composes file path from segments. If folder of file is absent, it will be created.
Parameters:
Name Type Argument Description paths
string <repeatable>
A sequence of paths or path segments.
Returns:
Composed path.
- Type
- string
-
<static> objOnScreenPos(obj, screen)
-
Gets object position on screen.
Parameters:
Name Type Description obj
object Object which should be on screen.
screen
object Screen object.
Throws:
-
If object isn't located on screen.
- Type
- Error
Returns:
Object position on screen.
- Type
- object
-
-
<static> sleep(timeout [, blocking])
-
Makes delay (sleep) during code execution.
Parameters:
Name Type Argument Default Description timeout
number Time to sleep, ms.
blocking
boolean <optional>
false Flag whether sleep should be block code execution.
Returns:
-
If sleep isn't blocking.
- Type
- Promise.<void>
-
If sleep is blocking.
- Type
- undefined
-
-
<static> splitBy(s, d)
-
Splits string to array by delimiter.
Parameters:
Name Type Description s
string String to split.
d
char String delimiter.
- Source:
Returns:
- Type
- array.<string>
Example
U.splitBy("a, b, c", ","); // ['a', 'b', 'c']
-
<static> subFolders(dir [, opts])
-
Gets subfolders of directory.
Parameters:
Name Type Argument Description dir
string Path to directory.
opts
object <optional>
Options.
Properties
Name Type Argument Default Description nameOnly
boolean <optional>
false Gets only folder names. By default, full paths.
Returns:
Sequence of results.
- Type
- Array.<string>
-
<static> textContains(string, words)
-
Checks if text contains words or no.
Parameters:
Name Type Description string
string Original text.
words
string Checking words.
- Source:
Returns:
true
if text contains words,false
otherwise.
- Type
- boolean
Example
U.textContains("hello world", "hello world"); // true
-
<static> toKebab(str)
-
Transforms string to kebab case. Replace all symbols, except numbers, chars and dots with dashes.
Parameters:
Name Type Description str
string String to transform.
Returns:
Transformed string.
- Type
- string
-
<async, static> waitDuring(predicate [, opts])
-
Waits during a time that predicate returns truly value.
Parameters:
Name Type Argument Description predicate
function Function which should return truly value during timeout.
opts
object <optional>
Options.
Properties
Name Type Argument Default Description timeout
number <optional>
1 Time to wait predicate result, sec.
polling
number <optional>
0.1 Time to poll predicate result, sec.
Returns:
-
false
if predicate didn't return truly value during expected time.- Type
- Promise.<boolean>
-
Predicate truly value.
- Type
- Promise.<object>
-
-
<async, static> waitFor(predicate [, opts])
-
Waits for predicate returns truly value.
Parameters:
Name Type Argument Description predicate
function Function which should return truly value during timeout.
opts
object <optional>
Options.
Properties
Name Type Argument Default Description timeout
number <optional>
1 Time to wait for predicate result, sec.
polling
number <optional>
0.1 Time to poll predicate result, sec.
Returns:
-
false
if predicate didn't return truly value during expected time.- Type
- Promise.<boolean>
-
Predicate truly value.
- Type
- Promise.<object>
-
-
<static> wrap(wrappers, target)
-
Wraps function inside other functions.
Parameters:
Name Type Description wrappers
Array.<function()> List of functions which will wrap target.
target
function Target function which will be wrapped.
Returns:
Wrapping function.
- Type
- function
-
<inner> clearEmptyFolders(folder)
-
Clears empty folders recursive.
Parameters:
Name Type Description folder
string Path to root folder.
-
<inner> switchColor( [opts])
-
Returns function which switches message color.
Parameters:
Name Type Argument Description opts
object <optional>
Options.
Properties
Name Type Argument Default Description c1
string <optional>
magenta Color #1.
c2
string <optional>
cyan Color #2.
Returns:
Function to switch color of passed text in terminal.
- Type
- function