SirLenz0rlot SirLenz0rlot - 3 months ago 25
Javascript Question

Intern JS - asynchronous hook before test definition?

I'd like to do an asynchronous action before defining my tests. For example, load a

jsdom
environment.
When doing this, intern runs 0 tests.
What would be the right way to do this?
I cant do this in the config itself, as the config needs to be loaded in order for intern to find
jsdom
.

my intern config loads the following file:

define( [
"intern/dojo/node!jsdom"
], function(
jsdom
)
{
"use strict";

var body = "";
var scripts = [];

jsdom.env( body, scripts, function( err, window )
{
define( [
"./test_MyRenderer",
], function()
{
} );
} );
} );


test_Renderer, defines the actual tests

define( [
"intern!bdd",
"intern/chai!expect",

"src/Renderer"
], function(
bdd,
expect,

Renderer
)
{
"use strict";

bdd.describe( "Renderer", function()
{
it( ...
it( ...
} );

Answer

The Intern config file can have setup and teardown methods, just like a test suite. These will be run before testing begins and after it finishes. This is an official, but as yet poorly documented feature.