Skip to content

Interface "exports" not working in browser #2198

@ScottFreeCode

Description

@ScottFreeCode

Getting error due to module not being defined, no tests detected because of that error in the JS file.

Windows 8.1, IE 11 & Firefox 45.0.1, Mocha 2.4.5

Works in Mocha commandline. Also works in browser if I use BDD interface instead of exports interface.

./index.html:

<!DOCTYPE html>
<html>
<head>

<link rel="stylesheet" href="./node_modules/mocha/mocha.css" />
<script src="./node_modules/mocha/mocha.js"></script>
<script>mocha.setup("exports")</script>
<script src="./test/X.js"></script>
<script>
document.addEventListener("readystatechange",function initialize(){
    if (document.readyState == "interactive") {
        mocha.checkLeaks()
        mocha.run()
        document.removeEventListener("readystatechange",initialize)
    }
})
</script>

</head>
<body>

<div id="mocha"></div>

</body>
</html>

./test/X.js:

;(function(){"use strict"

module.exports = {
    "foo": function bar(done) {
        setTimeout(done,10)
    },
    "bar": function foo() {
        throw new Error("FAILED TEST!")
    }
}

}())

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions