Members
-
$ :Steps
-
Steps collection.
Type:
- Source:
- See:
-
- steps to get more details about its methods.
-
allure
-
Allure helper.
- Source:
-
CONF
-
GlaceJSconfig.- Source:
- See:
-
- config to get more details about its options.
-
reporters :Array.<object>
-
Registered reporters.
Type:
- Array.<object>
- Source:
-
sinon
-
SinonJSis pretty nice lib for mocking.- Source:
-
stubObject
-
Stubs object with its properties recursively.
- Source:
Methods
-
after(func)
-
Global function, existing in
glacetests, which createafterhook.afterhook executes after all chunks in test or all tests in scope / suite / session.Parameters:
Name Type Description funcfunction Hook function. Can be
asynctoo.- Source:
Examples
after chunks
test("my test", () => { after(() => { doSomeThing(); }); chunk("first chunk", () => { doSomeThingAgain(); }); chunk("second chunk", () => { andDoSomeThingAgain(); }); });after tests
suite("my suite", () => { after(async () => { await db.connect(); }); test("first", () => { chunk(async () => { await db.query("select * from users"); }); }); test("second", () => { chunk(async () => { await db.query("select * from products"); }); }); }); -
afterChunk(func)
-
Global function, existing in
glacetests, which createsafterChunkhook.afterChunkhook executes after each chunk in test.Parameters:
Name Type Description funcfunction Hook function.
- Source:
Example
test("Some test", () => { afterChunk(() => { someFunc(); }); chunk("Chunk #1", () => { someFunc(); }); chunk("Chunk #2", () => { someFunc(); }); }); -
before(func)
-
Global function, existing in
glacetests, which createbeforehook.beforehook executes before all chunks in test or all tests in scope / suite / session.Parameters:
Name Type Description funcfunction Hook function. Can be
asynctoo.- Source:
Examples
before chunks
test("my test", () => { before(() => { doSomeThing(); }); chunk("first chunk", () => { doSomeThingAgain(); }); chunk("second chunk", () => { andDoSomeThingAgain(); }); });before tests
suite("my suite", () => { before(async () => { await db.connect(); }); test("first", () => { chunk(async () => { await db.query("select * from users"); }); }); test("second", () => { chunk(async () => { await db.query("select * from products"); }); }); }); -
beforeChunk(func)
-
Global function, existing in
glacetests, which createsbeforeChunkhook.beforeChunkhook executes before each chunk in test.Parameters:
Name Type Description funcfunction Hook function.
- Source:
Example
test("Some test", () => { beforeChunk(() => { someFunc(); }); chunk("Chunk #1", () => { someFunc(); }); chunk("Chunk #2", () => { someFunc(); }); }); -
chunk( [name] [, opts], func)
-
Global function, existing in
glacetests, which creates test chunk.chunkis independently executed part oftest. It means that even if first chunk is failed, other will be executed in any case.testshould contain as minimum onechunk.Parameters:
Name Type Argument Default Description namestring <optional>
null Name of chunk.
optsobject <optional>
Chunk options.
Properties
Name Type Argument Default Description retrynumber <optional>
<nullable>
null Number of chunk retries on failure. Overrides config and test settings.
timeoutnumber <optional>
<nullable>
null Time limit to execute chunk, sec. Overrides config and test settings.
funcfunction Callback function with test payload. Can be
asynctoo.- Source:
Examples
Anonymous chunk
test("My test", () => { chunk(() => { var a = 5; expect(a).to.be.equal(2); }); });Named chunk
test("My test", () => { chunk("My chunk", () => { var a = 5; expect(a).to.be.equal(2); }); });Chunk with options
test("My test", () => { chunk("My chunk", { retry: 2, timeout: 1 }, () => { var a = 5; expect(a).to.be.equal(2); }); });Several chunks in test
test("My test", () => { chunk("first chunk", () => { expect(2).to.be.equal(3); }); chunk("second chunk", () => { expect(3).to.be.equal(3); }); });Async chunk
test("My test", () => { chunk(async () => { await Promise.resolve("done!"); }); }); -
expect(actualValue)
-
chaijsexpectfunction.Parameters:
Name Type Description actualValue* Some actual value which should be checked.
- Source:
- See:
-
- chaijs to get more details about `expect` usage.
Example
expect(1).to.be.equal(1); expect(2).to.be.gte(0);
-
forEachLanguage( [name] [, fixtures] [, opts], func)
-
Iterates test chunks through all languages specified in config or options.
It's applicable for multilingual application. If list of languages is specified, it will be used firstly. Otherwise from configuration.
Parameters:
Name Type Argument Default Description nameobject <optional>
"for language" Iterator namespace (will be report).
fixturesArray.<function()> <optional>
Involved fixtures list.
optsobject <optional>
Options.
Properties
Name Type Argument Default Description languagesArray.<string> <optional>
<nullable>
List of tested languages.
chunkRetrynumber <optional>
0 Number of chunk retries on failure. Overrides config value for concrete test chunks.
chunkTimeoutnumber <optional>
<nullable>
null Time to execute chunk or hook, sec.
funcfunction Function with test steps.
- Source:
Example
test("Some test", ctx => { forEachLanguage(lang => { chunk(() => { // payload }); }); }); -
glaceRun(cb)
-
Runs glace framework.
Parameters:
Name Type Description cbfunction Callback.
-
help(d, cb)
-
Help description.
Parameters:
Name Type Description dfunction Function to process option description.
cbfunction Callback to expand default help.
-
run(cb)
-
Runs tests.
- executes
runner.jsfile, which is entry point to load and execute files with tests - connects custom reporter to
mochajs.
Parameters:
Name Type Description cbfunction Callback.
- executes
-
scope(name [, fixtures] [, opts], func)
-
Execute tests scope.
Parameters:
Name Type Argument Description namestring Scope name.
fixturesArray.<function()> <optional>
List of fixtures.
optsobject <optional>
Scope options.
Properties
Name Type Argument Description chunkRetrynumber <optional>
Number of chunk retries on failure.
chunkTimeoutnumber <optional>
Time to execute chunk or hook, sec.
funcfunction Callback function with test cases.
- Source:
Example
scope("Some test scope", () => { test("Some test name", () => { before(() => { someFunc(); }); chunk("chunk #1", () => { someFunc(); }); chunk("chunk #2", () => { someFunc(); }); }); }); -
session( [name] [, fixtures], func)
-
Executes tests session.
Parameters:
Name Type Argument Default Description namestring <optional>
Session name. By default it includes start date time.
fixturesobject <optional>
[] Session fixtures.
funcfunction Function with test cases.
- Source:
Example
session(() => { test("Test #1", () => { chunk("Chunk #1", () => { someFunc(); }); chunk("Chunk #2", () => { someFunc(); }); }); test("Test #2", () => { chunk("Chunk #1", () => { someFunc(); }); chunk("Chunk #2", () => { someFunc(); }); }); }); -
suite(name [, fixtures] [, opts], func)
-
Creates tests suite.
Parameters:
Name Type Argument Description namestring Suite name.
fixturesArray.<function()> <optional>
List of fixtures.
optsobject <optional>
Suite options.
Properties
Name Type Argument Description chunkRetrynumber <optional>
Number of chunk retries on failure.
chunkTimeoutnumber <optional>
Time to execute chunk or hook, sec.
funcfunction Callback function with test cases.
- Source:
Example
suite("Some test suite", () => { test("Some test name", () => { before(() => { someFunc(); }); chunk("chunk #1", () => { someFunc(); }); chunk("chunk #2", () => { someFunc(); }); }); }); -
test(name [, opts] [, fixtures], func)
-
Global function, existing in
glacetests, which creates test case.Parameters:
Name Type Argument Description namestring Name of test case. By default, should be unique in session. But uniqueness check can be skipped with CLI option
--dont-check-names.optsobject <optional>
Options.
Properties
Name Type Argument Default Description skipboolean | string <optional>
false Flag to skip test or skip reason message.
retrynumber <optional>
<nullable>
null Number of test retries on failure. Overrides config settings.
chunkRetrynumber <optional>
<nullable>
null # Number of chunk retries on failure. Overrides config settings.
chunkTimeoutnumber <optional>
<nullable>
null # Time to execute chunk or hook, sec. Overrides config settings.
fixturesArray.<function()> <optional>
Involved fixtures list.
funcfunction Сallback function with chunks and hooks.
- Source:
Examples
Simple test
test("Some test", () => { chunk("Some chunk", () => { someFunc(); }); });Test with retry
test("Test with retry", { retry: 2 }, () => { chunk(() => { someFunc(); }); });Test with fixtures
test("Test with fixtures", null, [fix_func_1, fix_func_2], () => { chunk(() => { someFunc(); }); });