Created
September 25, 2017 17:16
-
-
Save anonymous/caba0883254a2349c5615df8e9286665 to your computer and use it in GitHub Desktop.
Mocha ES Modules Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Mocha from "mocha" | |
export default new Mocha() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mocha from "./mochainstance.mjs" | |
mocha.suite.emit( | |
"post-require", | |
global, | |
"If anything uses the file argument, you'd actually need one pre-require, require and post-require per test file with the test file name hardcoded here", | |
mocha); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mocha from "./mochainstance.mjs" | |
mocha.suite.emit( | |
"pre-require", | |
global, | |
"If anything uses the file argument, you'd actually need one pre-require, require and post-require per test file with the test file name hardcoded here", | |
mocha); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mocha from "./mochainstance.mjs" | |
mocha.suite.emit( | |
"require", | |
null /* if this is actually needed... then like the file argument, you'd need one of this file per test file to import the test file and pass the test file here */, | |
"If anything uses the file argument, you'd actually need one pre-require, require and post-require per test file with the test file name hardcoded here", | |
mocha); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "./prerequire.mjs" | |
import "./test-forwardslash-file1.mjs" | |
import "./require.mjs" | |
import "./postrequire.mjs" | |
import "./prerequire.mjs" | |
import "./test-forwardslash-file2.js" | |
import "./require.mjs" | |
import "./postrequire.mjs" | |
import "./prerequire.mjs" | |
import "./test-forwardslash-file3.mjs" | |
import "./require.mjs" | |
import "./postrequire.mjs" | |
import mocha from "./mochainstance.mjs" | |
mocha.run(function(failures) { | |
process.on("exit", function() { | |
process.exit(failures > 0 ? 1 : 0); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe("ES Module file 1", function() { | |
it("should load this test", function() {}) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe("CommonJS Module file 2", function() { | |
it("should load this test", function() {}) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe("ES Module file 3", function() { | |
it("should load this test", function() {}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment