mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
198 lines
3.1 KiB
JavaScript
198 lines
3.1 KiB
JavaScript
var selftest = require('../tool-testing/selftest.js');
|
|
var Sandbox = selftest.Sandbox;
|
|
|
|
selftest.define("mainModule", function () {
|
|
const s = new Sandbox();
|
|
s.createApp("app-config-mainModule", "app-config");
|
|
s.cd("app-config-mainModule");
|
|
|
|
// For meteortesting:mocha to work we must set test broswer driver
|
|
// See https://github.com/meteortesting/meteor-mocha
|
|
s.set("TEST_BROWSER_DRIVER", "puppeteer");
|
|
|
|
const run = s.run(
|
|
"test",
|
|
"--full-app",
|
|
"--driver-package", "meteortesting:mocha"
|
|
);
|
|
|
|
run.waitSecs(60);
|
|
run.match("App running at");
|
|
|
|
function check(mainModule, errorPattern) {
|
|
writeConfig(s, run, mainModule, errorPattern);
|
|
}
|
|
|
|
check();
|
|
|
|
check(null);
|
|
|
|
check("oyez", /Could not resolve meteor.mainModule/);
|
|
|
|
check({});
|
|
|
|
check(false);
|
|
|
|
check({
|
|
client: false,
|
|
server: "abc",
|
|
});
|
|
|
|
check({
|
|
client: "abc",
|
|
server: false,
|
|
});
|
|
|
|
check({
|
|
web: false,
|
|
});
|
|
|
|
check({
|
|
os: false,
|
|
});
|
|
|
|
check({
|
|
client: "a",
|
|
os: "bc",
|
|
});
|
|
|
|
check({
|
|
client: "b.js",
|
|
server: "abc",
|
|
});
|
|
|
|
check({
|
|
client: "./c",
|
|
server: "/ac",
|
|
});
|
|
|
|
check({
|
|
server: "./a",
|
|
web: "ab",
|
|
});
|
|
|
|
check({
|
|
client: "ac.js",
|
|
os: "a",
|
|
});
|
|
|
|
check({
|
|
web: "bc",
|
|
server: "a",
|
|
});
|
|
|
|
check({
|
|
server: "b.js",
|
|
client: "abc",
|
|
});
|
|
|
|
check({
|
|
client: "abc",
|
|
});
|
|
|
|
check({
|
|
server: "b.js",
|
|
});
|
|
|
|
check({
|
|
client: "/ac",
|
|
server: "./c",
|
|
});
|
|
|
|
check({
|
|
os: "ab",
|
|
client: "./a",
|
|
});
|
|
|
|
check({
|
|
server: "ac.js",
|
|
web: "a",
|
|
});
|
|
|
|
check(null);
|
|
|
|
check();
|
|
|
|
run.stop();
|
|
});
|
|
|
|
function writeConfig(s, run, mainModule, errorPattern) {
|
|
const json = JSON.parse(s.read("package.json"));
|
|
|
|
json.meteor = {
|
|
// Make sure the tests.js module is always loaded eagerly.
|
|
testModule: "tests.js"
|
|
};
|
|
|
|
if (typeof mainModule === "undefined") {
|
|
delete json.meteor.mainModule;
|
|
} else {
|
|
json.meteor.mainModule = mainModule;
|
|
}
|
|
|
|
s.write("package.json", JSON.stringify(json, null, 2) + "\n");
|
|
|
|
run.waitSecs(10);
|
|
|
|
if (errorPattern instanceof RegExp) {
|
|
run.match(errorPattern);
|
|
} else {
|
|
run.forbid(" 0 passing ");
|
|
run.match("SERVER FAILURES: 0");
|
|
run.match("CLIENT FAILURES: 0");
|
|
}
|
|
}
|
|
|
|
selftest.define("testModule", function () {
|
|
const s = new Sandbox();
|
|
s.createApp("app-config-mainModule", "app-config");
|
|
s.cd("app-config-mainModule");
|
|
|
|
// For meteortesting:mocha to work we must set test broswer driver
|
|
// See https://github.com/meteortesting/meteor-mocha
|
|
s.set("TEST_BROWSER_DRIVER", "puppeteer");
|
|
|
|
const run = s.run(
|
|
"test",
|
|
// Not running with the --full-app option here, in order to exercise
|
|
// the normal `meteor test` behavior.
|
|
"--driver-package", "meteortesting:mocha"
|
|
);
|
|
|
|
run.waitSecs(60);
|
|
run.match("App running at");
|
|
|
|
function check(mainModule) {
|
|
writeConfig(s, run, mainModule);
|
|
}
|
|
|
|
check();
|
|
|
|
check(false);
|
|
|
|
check({
|
|
client: "abc"
|
|
});
|
|
|
|
check({
|
|
server: "abc"
|
|
});
|
|
|
|
check({
|
|
client: "abc",
|
|
server: "abc"
|
|
});
|
|
|
|
check({
|
|
client: "abc",
|
|
server: false
|
|
});
|
|
|
|
check({
|
|
client: false,
|
|
server: "abc"
|
|
});
|
|
|
|
run.stop();
|
|
});
|