Classes
Members
-
<static> cwd
-
<static, constant> hostname
-
- Source:
Properties:
Name Type Description hostnamestring Host name of machine where
glacejsframework 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 stringstring 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
nullif 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 helpMessagestring <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 lArray.<Array> Array of arrays to combine.
pfunction <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 pushesetoc.- 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 sourcestring 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 dirstring Path to directory.
optsobject <optional>
Options.
Properties
Name Type Argument Default Description descboolean <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 dirstring Path to directory.
optsobject <optional>
Options.
Properties
Name Type Argument Default Description descboolean <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 reqRequest Client request.
Returns:
Request key according to its method, host, url.
- Type
- string
-
<static> help( [d])
-
Help
Parameters:
Name Type Argument Description dfunction <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 objobject Object which may be on screen.
screenobject Screen object.
optsobject <optional>
Options.
Properties
Name Type Argument Default Description fullyboolean <optional>
false Flag to check full presence on screen.
Returns:
trueif it is on screen,falseotherwise.- Type
- boolean
-
<async, static> killProcs(procName)
-
Helper to kill processes by name.
Parameters:
Name Type Description procNamestring Process name or chunk of name.
Returns:
- Type
- Promise.<void>
-
<static> makeFixture( [opts])
-
Glacefixtures factory.Provides easy way to make a fixture with hooks related with shared context.
Parameters:
Name Type Argument Description optsobject <optional>
Options.
Properties
Name Type Argument Description beforefunction <optional>
Callback of
beforehook.afterfunction <optional>
Callback of
afterhook.beforeChunkfunction <optional>
Callback of
beforeChunkhook.afterChunkfunction <optional>
Callback of
afterChunkhook.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 textstring Text where words are looked for.
wordsArray.<string> Filtered words.
firstMissedOnlyboolean <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 pathsstring <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 objobject Object which should be on screen.
screenobject 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 timeoutnumber Time to sleep, ms.
blockingboolean <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 sstring String to split.
dchar 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 dirstring Path to directory.
optsobject <optional>
Options.
Properties
Name Type Argument Default Description nameOnlyboolean <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 stringstring Original text.
wordsstring Checking words.
- Source:
Returns:
trueif text contains words,falseotherwise.
- 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 strstring 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 predicatefunction Function which should return truly value during timeout.
optsobject <optional>
Options.
Properties
Name Type Argument Default Description timeoutnumber <optional>
1 Time to wait predicate result, sec.
pollingnumber <optional>
0.1 Time to poll predicate result, sec.
Returns:
-
falseif 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 predicatefunction Function which should return truly value during timeout.
optsobject <optional>
Options.
Properties
Name Type Argument Default Description timeoutnumber <optional>
1 Time to wait for predicate result, sec.
pollingnumber <optional>
0.1 Time to poll predicate result, sec.
Returns:
-
falseif 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 wrappersArray.<function()> List of functions which will wrap target.
targetfunction Target function which will be wrapped.
Returns:
Wrapping function.
- Type
- function
-
<inner> clearEmptyFolders(folder)
-
Clears empty folders recursive.
Parameters:
Name Type Description folderstring Path to root folder.
-
<inner> switchColor( [opts])
-
Returns function which switches message color.
Parameters:
Name Type Argument Description optsobject <optional>
Options.
Properties
Name Type Argument Default Description c1string <optional>
magenta Color #1.
c2string <optional>
cyan Color #2.
Returns:
Function to switch color of passed text in terminal.
- Type
- function