Question

From the documentation (Emphasiss Mine)

Library files to load in script tags in the browser. This setting should normally not be used for node runs. If it is, files will be require'd. Value is an array of file names and/or glob patterns. Files are loaded in the order provided. It may include duplicates, e.g. ["test/lib/core.js", "test/lib/*/.js"], files will only be loaded once. testHelpers are loaded after libraries and sources, but before tests.

What does this mean, exactly? When they get require'd, what do they get included as? Under what variable name? I have some global methods (testSetUp and testTearDown) That I like to reuse between tests. According to this, I can only use these methods between tests when I'm testing in the browser, not when I'm testing in Node.

Here's my config file:

var config = module.exports;

config['Browser Tests'] = {
    rootPath: '../',
    environment: 'browser',
    sources: [
        'src/*.js'
    ],
    deps: [
        'submodules/d3/d3.v2.min.js'
    ],
    testHelpers: [
        'test/helpers/*.js'
    ],
    tests: [
        'test/test_*.js'
    ]
};

config["Node tests"] = {
    rootPath: '../',
    environment: "node",
    tests: [
        'test/test_*.js'
    ]
};
Was it helpful?

Solution

What the documentation is telling you is that the files will be required, but their exports will be lost. So unless your helpers modify global objects, this is not useful on node.

However, you are free to put shared helpers in a separate file and require yourself.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top