module()


module( name, lifecycle )

Description: Group related tests under a single label.

All tests that occur after a call to module() will be grouped into that module. The test names will all be preceded by the module name in the test results. You can then use that module name to select tests to run.

You can specify code to run before and after each test using the lifecycle argument.

Examples:

Example: Use the module() function to group tests together:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
module( "group a" );
test( "a basic test example", function() {
ok( true, "this test is fine" );
});
test( "a basic test example 2", function() {
ok( true, "this test is fine" );
});
module( "group b" );
test( "a basic test example 3", function() {
ok( true, "this test is fine" );
});
test( "a basic test example 4", function() {
ok( true, "this test is fine" );
});

Example: A sample for using the setup and teardown callbacks

1
2
3
4
5
6
7
8
module( "module A", {
setup: function() {
// prepare something for all following tests
},
teardown: function() {
// clean up after each test
}
});